|
Did you check the return values for the above (Red colored) function calls ? The other possibility is that (if the functions return success), the window might have brought up to top, but your some other code might be changing the order again.
Or, calling SetForegroundWindow() before displaying your context menu might help you.
- Malli...!
|
|
|
|
|
I have a problem setting bg-text color of static control on one of my dialog
I try to set the bg-text color of every static control on my dialog by
overriding OnCtrlColor (ON_WM_CTLCOLOR) of that dilaog
HBRUSH CCAESDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor == CTLCOLOR_STATIC || nCtlColor == CTLCOLOR_DLG){
COLORREF color = RGB(255,225,255);
pDC->SetBkColor(color);
return (HBRUSH)GetStockObject(WHITE_BRUSH);
}
else{
return hbr;
}
}
this work fine for all of my dialog (10 of them).
But it doesn't work on one dialog,all the bg-text of every static control turn into pink.
even if i remove the if-else block from my code any force setting bg-text color of evey control on dialog to white color ,it still doesn't work.
declare & initialized the variable color as a class's member doesn't help either.
Does anyone know what the cause of this problem?
Thank in advance.
|
|
|
|
|
Did you make a Bursh and did you return it instead return hbr?
|
|
|
|
|
I return WHITE_BRUSH when the control is STATIC (as demonstrate in code)
Only the background part of the text which is setting
by calling pDC->SetBkColor doesn't work
I have those code in all of my dialog and it usually work,only one dialog that had the problem.
sorry for my bad english
|
|
|
|
|
Your code sets the background color to pink....
what color are you expecting?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
everyone, thank for your answer.
Actually,My code set the background color to white (color = RGB(255,255,255))
I managed to fixed the problem by changing the dialog's font in GUI editor from "Ms Dialog Shell" to "Microsoft San Serif".
This is very strange. I guess it somekind of very obscure bug.
|
|
|
|
|
Hi,
I'm trying to resolve a Manifest issue. Member 'enhzflep' suggested some time ago that mainifest XML Code does not have to be included in the exe, but that it can be added as a separate XML file (MyProg.exe.Manifest) as an afterthought, rather than compiling it into the code.
I Proposed the following for an exe called Softguard Utility Program.
As soon as the Windows Loader sees this Manifest, it balks with Win32 error 140001. If I rename the exe file, it runs.
I'm doing at least something right in that the Windows Loader responds. The question is, What's wrong with the XML Code that makes the loader
balk. Better, How do I debug this issue. The Loader fails before the Debugger Starts.
Contents of MyProg.Exe.manifest
<pre><code><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"
processorArchitecture="X86"
name="SgBackup"
type="win32"/>
<description>Softguard Utility Program</description>
<!-- Softguard Utility Program -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2>
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly></code></pre>
thanks
Bram van Kampen
|
|
|
|
|
Hi Bram. Sorry to hear this is still giving you trouble.
I also just tried that manifest file with an app of mine and received an error on loading.
Here's one that I use, as generated by the ANSI version of ResEdit. ResEdit home[^]
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="CompanyName.ProductName.YourApp"
type="win32"
/>
<description>Your application description here.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
Another useful utility for manifests is: XP Style Hacker: http://www.snapfiles.com/get/xpstylehack.html[^]
|
|
|
|
|
Taking all this on board.
BTW Could there be restrictions on the loader to stop inappropriate behaviour e.g. hacking, if the manifest asks for elevated status on a further non specified program module ?
Bram van Kampen
|
|
|
|
|
Pleasure.
Not really too sure what the problem is with that XML file, though on looking at this one I have here, I notice that you only have 1 pair of assemblyIdentity tags - I'm leaning away from it being a privilege escalation problem, but more towards the manifest being improperly formed.
Just found a blog that discusses manifests a little. I've tried the first one fro the page and it works fine. I then changed the requestedExecutionLevel to level="requireAdministrator", it still seems fine. Though I can run it with a guest account on xp - I don't know if this is the expected behaviour or not.
Here's the blog I mentioned:
http://blogs.msdn.com/cjacks/archive/2006/09/08/745729.aspx[^]
Here's the 1st manifest from that page:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" processorArchitecture="*" version="1.0.0.0" name="MyApplication.exe"/>
<description>My totally awesome application</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" language="*" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" />
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
Good luck.
|
|
|
|
|
Hi,
Thanks, Got it working in the end.
Now I've to find a VISTA Machine to find out if the module can Modify
keys Stored under HKLM. That was the entire purpose of the excersise.
Thanks again for the Help.
Bram van Kampen
|
|
|
|
|
I try to define some kookeyboard hook.
But for some reason i getting error in the compile time
the code that maybe wrong is :
SetWindowsHookEx(WH_KEYBOARD_LL, keyboardHookAction, NULL, 0);
|
|
|
|
|
What's the error from the compiler?
Regards,
--Perspx
Don't trust a computer you can't throw out a window
-- Steve Wozniak
|
|
|
|
|
The error message is
error C3867: 'keyboardHookAction': function call missing argument list;
use '&::keyboardHookAction' to create a pointer to member
and the function that receive the keyboard hook event is declared in this way
keyboardHookAction(int code, int wParam, KBDLLHOOKSTRUCT lParam)
|
|
|
|
|
OK , but my hook need to catch all the keyboard event - all of them.
I think the way to do it is to set NULL as the third argument - and this what i did.
Where is my mistake ?
|
|
|
|
|
If you have declared keyboardHookAction as a class member, you must reference it with the class name, and a pointer symbol (&), for example &MyClass::keyboardHookAction .
And if you want to capture all keyboard events you need to put the hook procedure function in a DLL anyway - see this article for more information.
Regards,
--Perspx
Don't trust a computer you can't throw out a window
-- Steve Wozniak
|
|
|
|
|
How have you declared keyboardHookAction? Did you daclare it as a member of a
given class? PLS explain a little more ...
Thank you masters!
|
|
|
|
|
Try this:
::SetWindowsHookEx(WH_KEYBOARD_LL, HookFunction, AfxGetInstanceHandle(), 0);<br />
<br />
return TRUE;<br />
}<br />
<br />
LRESULT CALLBACK HookFunction(int nCode, WPARAM wParam, LPARAM lParam)<br />
{<br />
KBDLLHOOKSTRUCT *kbdllhookstruct = (KBDLLHOOKSTRUCT*)lParam;<br />
<br />
if(!(kbdllhookstruct->flags & 128 ))<br />
{<br />
DWORD dwKey = kbdllhookstruct->vkCode;<br />
<br />
if((GetKeyState(VK_SHIFT) & 32768) && (dwKey != VK_LSHIFT) && (dwKey != VK_RSHIFT))<br />
WriteToFile("<Shift+>");<br />
<br />
if((GetKeyState(VK_CONTROL) & 32768) && (dwKey != VK_LCONTROL) && (dwKey != VK_RCONTROL))<br />
WriteToFile("<Ctrl+>");<br />
<br />
if((GetKeyState(VK_MENU) & 32768) && (dwKey != VK_LMENU) && (dwKey != VK_RMENU))<br />
WriteToFile("<Alt+>");<br />
<br />
if(dwKey >= 0x30 && dwKey <= 0x5A)
WriteToFile((char*)&kbdllhookstruct->vkCode);<br />
else<br />
{<br />
switch(dwKey)<br />
{<br />
case VK_BACK:<br />
WriteToFile("<BackSpace>"); break;<br />
<br />
}<br />
}<br />
}<br />
<br />
return 0;<br />
}
www.logicsims.ir
|
|
|
|
|
Thanx! But I think he doesn't need a fish, he's gonna learn how to catch it!
Thank you masters!
|
|
|
|
|
|
Dont worry it was a leak memory!
|
|
|
|
|
And who R U? his causin?
Thank you masters!
|
|
|
|
|
Hi Guys
I am working with Visual Stusios 2005.
I have a solution with 2 projects in it.
Can I call a static member function that is declared in one project from the other project?
OtherProjectClass::StaticMemberFunction(variables);
At the moment I get error LNK2019
Thanks
|
|
|
|
|
You can export the class from the project that implements the class:
class __declspec(dllexport) test
{
public:
static void StaticMemberFunction();
};
void test::StaticMemberFunction()
{
}
Then on the consumer side, import the class:
class __declspec(dllimport) test
{
public:
static void StaticMemberFunction();
};
...
test::StaticMemberFunction();
Note that it's nicer to use a macro that expands to __declspec(dllexport)
or __declspec(dllimport) depending on the definition of a build-type macro:
#if defined(BUILDINGDLL)
#define MYIMPORTEXPORT __declspec(dllexport)
#else
#define MYIMPORTEXPORT __declspec(dllimport)
#endif
Then both sides can share the same header file for the class, making
maintainability easier (if the class changes you don't have to remember
to change it in two places):
class MYIMPORTEXPORT test
{
public:
static void StaticMemberFunction();
};
*EDIT* I forgot to mention - you'll need to add the import library<br />
for the implementing module to the importing project's linker input settings.
Mark Salsbery
Microsoft MVP - Visual C++
modified on Saturday, September 20, 2008 4:33 PM
|
|
|
|
|
Thanks for the comprehensive answer Mark. Really appreciate it
|
|
|
|