Hi I'm trying to make a virtual keyboard and having problems with the
focusing and seeing to that the keyboard is always on top.
If I don't care about the keyboard being on top and use the following
method when I press a virtual key, just before generating the
keyevent, the focus will (at least some times) be set to the right
window and everything's fine. The window that had focus before I
pressed the keyboard gets the keystroke.
hwnd is the handle to the keyboard
void resetFocusToLastOwner(HWND hwnd){
HWND hwndNext = GetNextWindow(hwnd, GW_HWNDNEXT);
HWND hwndAnce = GetAncestor(hwndNext,GA_ROOTOWNER);
SetForegroundWindow(hwndAnce);
}
Well if I first set the keyboard to be always on top with the
following method
void SetToBeOnTop(HWND hwnd){
SetWindowPos(hwnd, HWND_TOPMOST, 0 ,0 ,0 ,0, SWP_NOACTIVATE |
SWP_NOSIZE);
}
then I cant find the right handle to the window that had focus before
I pressed the keyboard any more, I'm new to windows API, and if anyone
knows how to do this please tell me or point me in the right direction
Regards Linus.