Ok, here's the deal. I am making a dialog based app. I have a hook setup when you press F12 while using another app and it brings up a callback function that is a global. In the callback function I want to have it set my app to the Top-most window. here is what I have tried... What am I doing wrong?
HWND ghWndMain = NULL; //Is a global to CLLTrainerDlg
LRESULT CALLBACK KeyboardHook(int nCode,
WPARAM wParam,
LPARAM lParam)
{
BOOL huh = FALSE;
if (nCode == HC_ACTION)
{
if (wParam == VK_F12 && !GetAsyncKeyState(VK_F12))
{
huh = ::SetWindowPos(ghWndMain,
HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE & SWP_SHOWWINDOW);
if (!huh)
{
AfxMessageBox("Cannot set
on top!", MB_OK);
return 1;
}
}
}
return CallNextHookEx(ghHook, nCode, wParam, lParam);
}
Maybe I'm not using the Hwnd of the main dialog app right, but I can't figure out how to get it. Can someone PLEASE help!! The callback works fine, and if I just put in a Messagebox instead of all that crap everything works, it just won't make my app topmost for some reason. Thanks in advance! [sig][/sig]
HWND ghWndMain = NULL; //Is a global to CLLTrainerDlg
LRESULT CALLBACK KeyboardHook(int nCode,
WPARAM wParam,
LPARAM lParam)
{
BOOL huh = FALSE;
if (nCode == HC_ACTION)
{
if (wParam == VK_F12 && !GetAsyncKeyState(VK_F12))
{
huh = ::SetWindowPos(ghWndMain,
HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE & SWP_SHOWWINDOW);
if (!huh)
{
AfxMessageBox("Cannot set
on top!", MB_OK);
return 1;
}
}
}
return CallNextHookEx(ghHook, nCode, wParam, lParam);
}
Maybe I'm not using the Hwnd of the main dialog app right, but I can't figure out how to get it. Can someone PLEASE help!! The callback works fine, and if I just put in a Messagebox instead of all that crap everything works, it just won't make my app topmost for some reason. Thanks in advance! [sig][/sig]