Checkbox keyDown event in VB.NET

Dunamis

[H]Lurker Supreme[/H]
Joined
Jun 30, 2004
Messages
2,303
I'm using VB.NET 2003, anyone knows how to capture KeyDown event in CheckBox for navigation keys (up, down, left, right)? it seems that this event doesn't fire up for these keys, any other keys are fine.

Thanks. :)
 
No. Because the dialog handler wants to eat the message so you can navigate input focus around with the keyboard. You'll have to install a hook. I know how to do that in VB6, but not in VB.Net.
 
Thanks for the reply :)

I guess it's time to google "vb net control hook" :D
 
It's a "message hook".

I haven't played with VB.Net at all, so I really can't give you any leads. But this is fundamental to the way Windows works.

The input message is dispatched to the message pump. The mesage pump gets the message, then decides what to do with it. The first thing in its decision is calling IsDialogMessage() and then TranslateMessage() to let Windows decide who the dialog manager would let the user navigate through the controls. While you might not have dialog present, VB (or, the WinForms runtime, really) is calling these same functions for you in order to get the same processing done.
 
Looks like you can get it by overriding ProcessKeyPreview(). I'd guess this is called for input messges before the WinForms message processing code calls the Windows APIs I was mentioning.

You can sniff the key, then decide what to do with the dispatch of the message. The docs explain the rules for signalling what happened and handling the dispatch with the base class.
 
sweet, I'll try that on monday :)
when I get back to work, sigh... don't you hate mondays!
 
Back
Top