May 12, 2024, 12:52:42 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Custom Control and Arrow keys

Started by LarryMc, November 12, 2008, 10:56:44 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

November 12, 2008, 10:56:44 PM Last Edit: November 12, 2008, 11:10:02 PM by Larry McCaughn
Working on a new custom control.
The control needs to respond to the +,- keys along with the left, right, up, down arrow keys.

This is the abbreviated setup I have in the custom control's procedure(handler)
CASE WM_KEYUP
SELECT WPARAM
CASE 187
CASE& 107               '+ zoom in
/* code here */
CASE 189
CASE& 109               '- zoom out
/* code here */
CASE 37               'left arrow
/* code here */
CASE 39               'right arrow
/* code here */
CASE 38               'up arrow
/* code here */
CASE 40               'down arrow
/* code here */
ENDSELECT

As part of my development I'm running a program that is a parent dialog with 3 of my custom controls as children.

I click on one of the 3 controls to gain focus and the +,- keys work as I would expect and desire.

When I use one of the arrow keys I initally get the response I expected in the control but if I press one of the arrow keys again the response is not in the same control.  It responds in the next control in the direction of the arrow I pressed.

So, besides triggering the response I expect it is also acting like when you use the tab key to move through a set of controls.

How do I stop the unwanted action?  Is there some other message that is being generated when I press a arrow key that needs to be trapped?

I didn't see anything in styles or extended styles that looked like it would help me.
I looked in MSDN under "keyboard " and didn't find anything that I could understand that might help me.

Larry

REVISION:  Discovered if I change WM_KEYUP to WM_KEYDOWN the +,- still work but the arrow keys don't fire that case statement. ????
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Ionic Wind Support Team

Ionic Wind Support Team

Ionic Wind Support Team

This quote should solve it for you:

"When the user presses a direction key, the system first determines whether the current control having the input focus processes the direction keys. The system sends a WM_GETDLGCODE message to the control and if the control returns the DLGC_WANTARROWS value, passes the key to the control. Otherwise, the system uses the GetNextDlgGroupItem function to determine the next control in the group."

Paul.
Ionic Wind Support Team

LarryMc

Thanks,
Another one I would never have found.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Can't get much easier than this (when you know what you're doing)
case WM_GETDLGCODE
return DLGC_WANTARROWS


Thanks again

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library