Can NOT Get the WM_HOTKEY msg

S

steel

Hi, everyone, I am fighting with a project with 5 Hotkey registerd. but

when the VK code is 66 67 68 69 71, the WM_HotKey msg can not fired,
but if changed the VK code to 117 ... 121 , the Project runs well. I
have look up the MSDN, but get no answerns yet.Can anyone make me known

the reason?

I have found that when the Vitual KeyCode is 66-70, the system viewed
it as normal keyEvent, Not HotKey event.
the related code:
public enum KeysHardware : int
{
Hardware1 = 66, //117,//
Hardware2 = 67, //118,//
Hardware3 = 68, //119,//
Hardware4 = 69, //120,//
Hardware5 = 71 // 121 //
}


public static void RegisterRecordKey(IntPtr hWnd)
{
bool Ret;
Ret = UnregisterFunc1(KeyModifiers.None,
(int)KeysHardware.Hardware1);
Ret = RegisterHotKey(hWnd, (int)KeysHardware.Hardware1,
KeyModifiers.None, (int)KeysHardware.Hardware1);


Ret = UnregisterFunc1(KeyModifiers.None,
(int)KeysHardware.Hardware2);
Ret = RegisterHotKey(hWnd, (int)KeysHardware.Hardware2,
KeyModifiers.None, (int)KeysHardware.Hardware2);


Ret = UnregisterFunc1(KeyModifiers.None,
(int)KeysHardware.Hardware3);
Ret = RegisterHotKey(hWnd, (int)KeysHardware.Hardware3,
KeyModifiers.None, (int)KeysHardware.Hardware3);


Ret = UnregisterFunc1(KeyModifiers.None,
(int)KeysHardware.Hardware4);
Ret = RegisterHotKey(hWnd, (int)KeysHardware.Hardware4,
KeyModifiers.None, (int)KeysHardware.Hardware4);
}


any suggestions and solutions will be very appreciated.
 
P

Peter Foot [MVP]

The hardware keys are usually send with the Windows key modifier. Also check
that your hWnd is valid that you pass to RegisterHotKey. If you are using
..NETCF v2.0 you can use the Microsoft.WindowsCE.Forms.HardwareButton
component.

Peter
 
S

steel

Dear Peter, Thanks for your reply.
I have checked my hWnd, it IS valid, and RegisterHotKey's retern value
is also right. the same code, another group of Vitual KeyCode(117-121)
can run correctly.
It seems that The HardwareButton is only supported by PPC platform,
and my platform is winCE 5.0.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top