-
May 19th, 2005, 03:08 AM
#1
fail to catch WM_KEYDOWN in a modeless dialog
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
-
May 19th, 2005, 03:48 AM
#2
Re: fail to catch WM_KEYDOWN in a modeless dialog
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
-
May 19th, 2005, 03:50 AM
#3
Re: fail to catch WM_KEYDOWN in a modeless dialog
hi,
already done that, with no help.
i dont even see key strokes in the Spy++.
very wired...
-
May 19th, 2005, 05:15 AM
#4
Re: fail to catch WM_KEYDOWN in a modeless dialog
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?
Life is short, enjoy it with a smile as long as it lasts.
User error. Replace User and press any key when ready. - Anonymous
-
May 19th, 2005, 10:04 AM
#5
Re: fail to catch WM_KEYDOWN in a modeless dialog
VK_RETRUN and VK_ESCAPE.
no matter what i try i fail to catch them.
-
May 19th, 2005, 10:24 AM
#6
Re: fail to catch WM_KEYDOWN in a modeless dialog
Originally Posted by neo_the_1
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.
-
May 19th, 2005, 10:34 AM
#7
Re: fail to catch WM_KEYDOWN in a modeless dialog
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
Please go vote for your country!
-
May 19th, 2005, 11:56 AM
#8
Re: fail to catch WM_KEYDOWN in a modeless dialog
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?
There are only 10 types of people in the world:
Those who understand binary and those who do not.
-
May 19th, 2005, 11:07 PM
#9
Re: fail to catch WM_KEYDOWN in a modeless dialog
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 strongly agree with this. As pointed out in other replies it will better if you try & override OnOK & OnCancel.
Life is short, enjoy it with a smile as long as it lasts.
User error. Replace User and press any key when ready. - Anonymous
-
May 20th, 2005, 05:12 AM
#10
Re: fail to catch WM_KEYDOWN in a modeless dialog
i forgot to mention that i remoed the OK\Cancel button.
i managed to catch WM_KEYDOWND in a child button.
thank you all.
-
May 20th, 2005, 08:39 AM
#11
Re: fail to catch WM_KEYDOWN in a modeless dialog
Originally Posted by neo_the_1
i forgot to mention that i remoed the OK\Cancel button.
i managed to catch WM_KEYDOWND in a child button.
thank you all.
Why did you do that?
There are only 10 types of people in the world:
Those who understand binary and those who do not.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|