IonicWind Software

IWBasic => GUI Central => Topic started by: LarryMc on November 12, 2008, 10:56:44 PM

Title: Custom Control and Arrow keys
Post by: LarryMc on November 12, 2008, 10:56:44 PM
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. ????
Title: Re: Custom Control and Arrow keys
Post by: Ionic Wind Support Team on November 12, 2008, 11:18:55 PM
http://msdn.microsoft.com/en-us/library/ms644995.aspx

Scroll down to:

Dialog Box Keyboard Interface

;)
Title: Re: Custom Control and Arrow keys
Post by: Ionic Wind Support Team on November 12, 2008, 11:22:02 PM
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.
Title: Re: Custom Control and Arrow keys
Post by: LarryMc on November 12, 2008, 11:43:23 PM
Thanks,
Another one I would never have found.

Larry
Title: Re: Custom Control and Arrow keys
Post by: LarryMc on November 13, 2008, 06:54:17 AM
Can't get much easier than this (when you know what you're doing)
case WM_GETDLGCODE
return DLGC_WANTARROWS


Thanks again

Larry