Virtual keyboard

L

Linus Sylv?n

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.
 
R

red floyd

Linus said:
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.

Try one of the MS newsgroups over on news.microsoft.com. You're very
off topic here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top