Unable to get key input 
Author Message
 Unable to get key input

I have a dlg with WS_VSCROLL style, then I add a list of
child dlgs to it to make a vertical list. I want to scroll
the list when user press up or down key. Then I add
OnKeyDown() to the list dlg. When user click one of the
child dlgs (list items), the child dlg calls
GetParent()->SetFocus(); I intend to let the list dlg get
the input focus.
But the OnKeyDown() is not called when i click the item
and press the keys. What goes wrong?? (I am sure that
GetParent()->SetFocus(); is called)


Wed, 03 Nov 2004 23:55:55 GMT  
 Unable to get key input
Hi!

First see the article, "Dialog Box Keyboard Interface", at the following URL...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winu...

Wherein it says that, "Because the dialog box keyboard interface uses direction keys to move between
controls in a dialog box, an application cannot use these keys to scroll the contents of any modal
dialog box or any modeless dialog box for which IsDialogMessage is called. When a dialog box has
scroll bars, the application must provide an alternate keyboard interface for the scroll bars".

Then see the article, "Dialog Box Default Message Processing", at this URL...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winu...

Wherein it says that the default handling of the WM_SETFOCUS message, "Sets the input focus to the
control identified by a previously saved control window handle. If no such handle exists, the
procedure sets the input focus to the first control in the dialog box template that is visible, not
disabled, and has the WS_TABSTOP style. If no such control exists, the procedure sets the input
focus to the first control in the template".

That done, you can probably circumvent things by looking for the WM_KEYDOWN message in an override
of PreTranslateMessage...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcli...
ateMessage.asp

...and looking for a WPARAM of VK_UP or VK_DOWN. Although you might also want to first ask the
control with the focus whether it wants the message...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winu...

HTH,

--
Jeff Partch [MVP]


Quote:
> I have a dlg with WS_VSCROLL style, then I add a list of
> child dlgs to it to make a vertical list. I want to scroll
> the list when user press up or down key. Then I add
> OnKeyDown() to the list dlg. When user click one of the
> child dlgs (list items), the child dlg calls
> GetParent()->SetFocus(); I intend to let the list dlg get
> the input focus.
> But the OnKeyDown() is not called when i click the item
> and press the keys. What goes wrong?? (I am sure that
> GetParent()->SetFocus(); is called)



Thu, 04 Nov 2004 01:09:09 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Getting all system key board input

2. getting key status in Soft Input Panel(SPI)

3. key by key unbuffered input on Un*x

4. CDIALOG : respond to PGUP-PGDN key (key input in general)

5. Unable to sync input and output streams

6. M0006: unable to pre-process input file

7. Unable to tap key press in modeless dlg when modal dlg is open from other dll

8. NT Service unable to access registry key.

9. ON_KEY_DOWN unable to capture VK_DOWN, VK_RIGHT and TAB key

10. Unable to capture the escape key during drag and drop in a CTreeCtrl

11. encryption key input

12. Multiple and Simultaneous Key input

 

 
Powered by phpBB® Forum Software