How can I get WM_KEYDOWN message in the CWnd-derived class?
-
I'm not getting WM_KEYDOWN at all, but I need a arrow button only. I'm try to handle a message in the OnKeyDown() handler and in the PreTranslateMessage() method. Best regards, Eugene Pustovoyt
ICQ UIN: 161325180
Then something else is swallowing the message - what on the dialog has the focus ? Christian Graus - Microsoft MVP - C++
-
Now what - dialog of CWnd?? With dialogs you'll never get this msg since always a child wnd has the focus. Dig into PreTranslateMessage() instead. ---------------------- ~hamster1
I'm understand, but how can I set a focus, if SetFocus() method has not effect. In the PreTranslateMessage() method I don't retrive a WM_KEYDOWN message too. Best regards, Eugene Pustovoyt
ICQ UIN: 161325180
-
Then something else is swallowing the message - what on the dialog has the focus ? Christian Graus - Microsoft MVP - C++
Yes, dialog has the focus. By press arrow button has effect in the last focused window (for example - CListBox). If I press TAB then after some steps I jump to the my CWnd::OnFocus() method. Best regards, Eugene Pustovoyt
ICQ UIN: 161325180
-
Yes, dialog has the focus. By press arrow button has effect in the last focused window (for example - CListBox). If I press TAB then after some steps I jump to the my CWnd::OnFocus() method. Best regards, Eugene Pustovoyt
ICQ UIN: 161325180
Eugene Pustovoyt wrote: Yes, dialog has the focus. By press arrow button has effect in the last focused window (for example - CListBox). Then, the dialog does not have the focus. How is this window being shown, is it a modeless dialog ? Christian Graus - Microsoft MVP - C++
-
Eugene Pustovoyt wrote: Yes, dialog has the focus. By press arrow button has effect in the last focused window (for example - CListBox). Then, the dialog does not have the focus. How is this window being shown, is it a modeless dialog ? Christian Graus - Microsoft MVP - C++
No, it's modal dialog Best regards, Eugene Pustovoyt
ICQ UIN: 161325180
-
No, it's modal dialog Best regards, Eugene Pustovoyt
ICQ UIN: 161325180
Then how can you be pressing tab to move the focus into the dialog ? Or did I misunderstand you ? Christian Graus - Microsoft MVP - C++
-
Then how can you be pressing tab to move the focus into the dialog ? Or did I misunderstand you ? Christian Graus - Microsoft MVP - C++
You're misunderstand me. When I press TAB then focus jump by all controls of the MODAL dialog and to my control (OnSetFocus method) too. Therefore I think a dialog do process WM_KEYDOWN message, but this message isn't arrive at my CWnd-derived class. Best regards, Eugene Pustovoyt
ICQ UIN: 161325180
-
You're misunderstand me. When I press TAB then focus jump by all controls of the MODAL dialog and to my control (OnSetFocus method) too. Therefore I think a dialog do process WM_KEYDOWN message, but this message isn't arrive at my CWnd-derived class. Best regards, Eugene Pustovoyt
ICQ UIN: 161325180
Oh - is your CWnd derived class a control on the dialog ? If that's the case, then the fact you need to press tab proves that your control does not have focus, and therefore does not get any keyboard messages. Christian Graus - Microsoft MVP - C++
-
Oh - is your CWnd derived class a control on the dialog ? If that's the case, then the fact you need to press tab proves that your control does not have focus, and therefore does not get any keyboard messages. Christian Graus - Microsoft MVP - C++
Yes, my CWnd-derived class is a control on the dialog. And how can set focus if SetFocus() method has not effect or how can I get WM_KEYDOWN message?? Best regards, Eugene Pustovoyt
ICQ UIN: 161325180
-
Yes, my CWnd-derived class is a control on the dialog. And how can set focus if SetFocus() method has not effect or how can I get WM_KEYDOWN message?? Best regards, Eugene Pustovoyt
ICQ UIN: 161325180
To get the message, you need the focus. Can't you set your control to be the one that recieves initial focus in the dialog editor ? Perhaps making it top of the tab order will do this ? Christian Graus - Microsoft MVP - C++
-
To get the message, you need the focus. Can't you set your control to be the one that recieves initial focus in the dialog editor ? Perhaps making it top of the tab order will do this ? Christian Graus - Microsoft MVP - C++
In my OnSetFocus() handler I call CWnd::OnSetFocus(pOldWnd) and just SetFocus(), but it has not effect to getting WM_KEYDOWN message. How another I can set a focus? Best regards, Eugene Pustovoyt
ICQ UIN: 161325180
-
In my OnSetFocus() handler I call CWnd::OnSetFocus(pOldWnd) and just SetFocus(), but it has not effect to getting WM_KEYDOWN message. How another I can set a focus? Best regards, Eugene Pustovoyt
ICQ UIN: 161325180
Which OnSetFocus handler ? YOu're saying you call OnSetFocus in the dialog, and the handler in your control calls it as well, as it's a composite control ? Christian Graus - Microsoft MVP - C++
-
Which OnSetFocus handler ? YOu're saying you call OnSetFocus in the dialog, and the handler in your control calls it as well, as it's a composite control ? Christian Graus - Microsoft MVP - C++
Probably it because my bad English. Start from begin step by step: 1. I wrote a Cwnd-derived control which must to get a WM_KEYDOWN 2. I'm put his to MODAL DEMO DIALOG 3. If I press TAB in my demo then I see as a focus jump from the control to the control. Focus also jump into WM_SETFOCUS handler of the my control CMyControl::OnSetFocus() 4. In the WM_SETFOCUS handler of the my control I call CWnd::OnSetFocus() or SetFocus() but it has not effect to getting a WM_KEYDOWN message. I can't get this message neither in the WM_KEYDOWN handler of the CMyControl nor in the CMyControl::PreTranslateMessage. Best regards, Eugene Pustovoyt
ICQ UIN: 161325180