titanandrews
Programmer
Hi All,
Has anyone ever set a global hook with SetWindowsHookEx and tried to "listen" for windows getting focus with any success? I have installed the following callback function for the WH_CBT function type. The hook is installed fine with no errors, but the only code I am getting inside the function is HCBT_CLICKSKIPPED a few times and then nothing. A google search has turned up a lot of this same scenario, but no one seemed to ever get a resolution. I was hoping someone here has had this issue before and knows what the problem is.
Many thanks in advance!!!
-B
Has anyone ever set a global hook with SetWindowsHookEx and tried to "listen" for windows getting focus with any success? I have installed the following callback function for the WH_CBT function type. The hook is installed fine with no errors, but the only code I am getting inside the function is HCBT_CLICKSKIPPED a few times and then nothing. A google search has turned up a lot of this same scenario, but no one seemed to ever get a resolution. I was hoping someone here has had this issue before and knows what the problem is.
Many thanks in advance!!!
-B
Code:
LRESULT CALLBACK FocusProc(int nCode,WPARAM wParam,LPARAM lParam)
{
if(nCode < 0)
return ::CallNextHookEx(*_pHook,nCode,wParam,lParam);
char buffer[20];
_itoa_s(nCode,buffer,10);
OutputDebugString(buffer);
if(nCode == HCBT_SETFOCUS)
{
HWND hWnd = ( HWND ) wParam;
TCHAR buf[256];
::GetWindowText(hWnd,buf,256);
//cout << "Focus" << buf << endl;
::OutputDebugString("Focus");
}
return ::CallNextHookEx(*_pHook,nCode,wParam,lParam);
}