- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Hello all,
I have a problem with the keyboard focus of my application.
The application consists of the main window, one OpenGL child window for graphical output and one control dialog.
Till nowI have managed to show some (sample)3D-bodies in the graphic window, and can interact (like rotate, switch light on/off) by the keyboard. The keyboard functions are processed via the WM_KEYDOWN message in the MainWindowProcedure.
However, I also want to be able to control my app via the control dialog. But if I use a control in my control dialog (right now only one check box for the light switch), the main window looses focus and consequently does no longer process my keyboard inputs. There is not even a WM_KEYDOWN message to the DialogProcedure, since the checkBox seems to gain the focus.
I triedchanging the focus back to the main window from my DialogControl (see below), but then my checkBox doesn't work any more, i.e. it stays active all the time.
INTEGER*4
FUNCTION CtrlDlgProc( hDlg, message, uParam, lParam )...
SELECT CASE (message) ...CASE (WM_COMMAND)
SELECT CASE (LOWORD(uParam))
CASE (IDC_LIGHTING)
WRITE (9,*) 'check_box'
CALL SwitchLight
ret=SetFocus(ghWndMain)
CtrlDlgProc = 0
...END FUNCTION CtrlDlgProc
How can I intercept the keystroke message or how can I tell my application to set the keyboard focus back to the main window after it processed the dialog events?
- Balises:
- Intel® Fortran Compiler
Lien copié
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Hmm,
after trying different stuff for about 2 hours it somehow does work now, and in exactly the same way I tried above.Though I still don't understand what happened because I thought I had put everything back in the original state, i.e. the state of 2 hours ago. Strange things are happening...
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Justclose the dialog (Alt +F4) and focuswill shift to the main window. The Tab key should take focus off the check box to the NC area. If the dialog is nonmodal the Tab will eventually get the main window into focus, I think.
Gerry
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
* Define your important keys in an accelerator table resource, load it using LoadAccelerators, and insert TranslateAccelerator in your message loop, as here. See MSDN entry. Additional caveat: accelerator keys won't work if you have modal dialogs active.
* Define a global WH_KEYBOARD hook, which will monitor all keypresses that occur in your application (more precisely, thread) before they reach any message loop. See this thread (from 5th post down). Take care to test the bit 31, and to always call CallNextHookEx with appropriate arguments.

- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Page imprimable