-
WM_KEYDOWN oddity
Probably a simple explanation for this, but it's eluded me so far. If I check for a WM_KEYDOWN message in the window procedure for a completely blank dialog window (ie. no controls, buttons etc.), it's detected, but if there are any controls in the resource script for the dialog box (even just a single line of static text), the WM_KEYDOWN message seemingly goes undetected. Any ideas?
-
I'm pretty sure it's due to your main window losing focus. If the HWND of your Main Window was hWnd, you'd have to use:
To return the focus back to your window, and the WM_KEYDOWN will fire again. You'll just have to find the areas in your code where it's appropriate to return the focus back to your main window and throw that in (I.e. after the creation of any new child windows).
The reason behind this is that in cases like an Edit Box, it wouldn't make sense if the user was typing in it, and at the same time firing off WM_KEYDOWNs, otherwise some pretty crazy things could be happening.
Alternatively:
Some controls (Static, Listbox, Button, etc.) can be created with the *_NOTIFY style. For a Listbox, it is LBS_NOTIFY, which sends Click notifications (the default doesn't send these messages). Other controls have their own special style for notification, while others, like the Edit, doesn't. You can read more about it here:
http://msdn.microsoft.com/library/de...divcontrol.asp
EDIT:
However, I don't think there is a style flag which changes any KeyPress notifications.
-
Thanks. I think I need to experiment a bit with Get/SetFocus() to determine/set where the keyboard focus needs to be.