Static int num=0;
Printf (" % d: % % x, 4 x % s \ n ", num++, MSG, GetMessageName (MSG), wParam);
The mouse and key code is as follows:
Case WM_LBUTTONDOWN:
{
HWND hwnd2=FindWindow (NULL, "* no title - notepad");
If (hwnd2!=NULL)
{
The SetForegroundWindow (hwnd2);
The SetActiveWindow (HWND);
Printf (" % Id \ n "this window, HWND);
Printf (" % active window Id \ n ", the GetActiveWindow ());
Printf (" keyboard focus % Id \ n ", GetFocus ());
}
return 0;
}
Case WM_LBUTTONUP:
{
Printf (" % Id \ n "this window, HWND);
Printf (" % active window Id \ n ", the GetActiveWindow ());
Printf (" keyboard focus % Id \ n ", GetFocus ());
return 0;
}
Case WM_KEYDOWN:
{
Printf (" button \ n ");
break;
}
The results are as follows:
Every click and activate the window first, and then activate the notepad, so cycle,
The problem is, every click once, keyboard input is in notepad, but through code detection, active window should now be the window
And activities through the timer detection, on the window with the keyboard focus is still the window, but why the keyboard in the notepad? And by the title bar, can see that it is the active window, what is this?
Who can explain?