Click to See Complete Forum and Search --> : Detecting particular keys in sub-classed window


leojose
January 16th, 2006, 04:43 AM
Hi all,

Here is the situation:
I have sub-classed a window and would like to get notification for 'Control key up' and 'Shift key up' events only.

My method:
monitor the WM_KEYUP events and check wParam for VK_CONTROL & VK_SHIFT

Why I don't like it:
The WM_KEYUP will be handled whenever a key is pressed. But I wan't to narrow it down to just the Control and Shift keys.

What I am looking for:
I read in MSDN that Ctrl, Shift, Alt etc. fall into System keys or Extended keys. Is there any Windows message that will signal only these type of events?

golanshahar
January 16th, 2006, 04:59 AM
Why I don't like it:
The WM_KEYUP will be handled whenever a key is pressed. But I wan't to narrow it down to just the Control and Shift keys.


you can still narrow it down, if you will put an if :)


if ( vk == VK_SHIFT )
{
// do something
}

so in all other cases nothing will happen, why isnt it enough for you? :confused:

Cheers

leojose
January 16th, 2006, 05:55 AM
why isnt it enough for you? :confused:

I just didn't wan't to load my system by monitoring all 'key up' events if it can be avoided.

The method you suggested was in my mind, but I was looking for an alternative if possible.

golanshahar
January 16th, 2006, 04:32 PM
I just didn't wan't to load my system by monitoring all 'key up' events if it can be avoided.

The method you suggested was in my mind, but I was looking for an alternative if possible.

not sure but maybe ::RegisterHotKey(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/registerhotkey.asp) can help you.

Cheers