Originally posted by canine
I can't get it to work, mabey a code sample? thanx anyway
Hmm..I see your point.........the SDK docs say that WM_KILLFOCUS can pass NULL as the wParam....but it seems to do this a lot....
Anyway...I tried the following...it is still not foolproof.....
Code:
case WM_KILLFOCUS:
hNewFocus = (HWND)wParam; //First Try
if(hNewFocus == NULL)
Sleep(2000);
hNewFocus = GetForegroundWindow();//Second Try
if(hNewFocus == NULL)
MessageBox(hwnd,"Error, could not find window","",MB_OK);
else
SendMessage(hNewFocus,WM_SETTEXT,0,
(LPARAM)"Damn you!! You stole my focus!!");
break;
That code tries to find the new window and change its title......
If NULL is passed by WM_KILLFOCUS, it waits 2 seconds and tries GetForegroundWindow().......
Its still far from practicle though...........