hi,
my application main window is a modeless dialog.
no matter what i did, i failed to catch the WM_KEYDOWN message.
anything that i miss about a modeless dialog ?
thanks
Printable View
hi,
my application main window is a modeless dialog.
no matter what i did, i failed to catch the WM_KEYDOWN message.
anything that i miss about a modeless dialog ?
thanks
Are you using MFC?
If you are then you can achieve what you want by overriding PreTranslateMessage. Not being able to catch WM_KEYDOWN etc is a common problem.
Have a look here: http://www.codeproject.com/dialog/pretransdialog01.asp
Or just google for WM_KEYDOWN dialog PreTranslateMessage! :-)
Markus
hi,
already done that, with no help.
i dont even see key strokes in the Spy++.
very wired...
Hi,
Are you trying to catch for any specific key or for all keys? Some keys not caught by OnKeyDown will be caught in OnChar. Can you tell us whcih key(s) you are trying to catch?
VK_RETRUN and VK_ESCAPE.
no matter what i try i fail to catch them.
instead of trying to trap those keys, you can handle OnOK() - which correspond to VK_RETURN and OnCancel() - VK_ESCAPE. This is the normal way of doing things.Quote:
Originally Posted by neo_the_1
Does it happen on a specific control, like a listcontrol??
You can check that in the properties you check the box : Want key input, or Want Return
I had trouble with that. Hopefully I needed to handle the RETURN key, so I overrode OnOK();
Marina
neo_the_1,
My advice is stay away from PreTranslateMessage. It is not a good place to do anything but translating accelerators, filtering tooltip messages, translating dialog messages.
Dialog that contains at least one control, never has focus.
Marina Vaillant already addressed first point: what control you are trying to do it?
Did you assign any accelerator keys?
What keystrokes are you trying to catch?
We need more information; what is exactly that is giving you a hard time?
I strongly agree with this. As pointed out in other replies it will better if you try & override OnOK & OnCancel.Quote:
My advice is stay away from PreTranslateMessage. It is not a good place to do anything but translating accelerators, filtering tooltip messages, translating dialog messages.
i forgot to mention that i remoed the OK\Cancel button.
i managed to catch WM_KEYDOWND in a child button.
thank you all.
:confused: :confused: :confused:Quote:
Originally Posted by neo_the_1
Why did you do that?