We are using C# with the CF v2.0 on WM 5.0. We have a requirement to trap
hardware buttons to prevent the associated actions while a particular
application has the focus. My team has had had no trouble doing this with
the HardwareButton & HardwareKeys entities for "normal" buttons, however this
process does not seem to work with the "Windows" button that (typically)
brings up the "Start Menu" pop-up. We even tried a WindowSink:MessageWindow
with a WndProc(Message) handler, but that doesn't get called by the button
either. None of us has been successful in finding an answer. Is there
something that will work?

Re: Trapping Hardware Buttons by dule

dule
Fri Jul 21 16:11:30 CDT 2006

Hi,
I have encountered the simillar problem on the Recon device and this is how
I have solved it:

typedef BOOL (__stdcall *UnregisterFunc1Proc)( UINT, UINT );


void DisableWinKey (HWND hWnd)
{
HINSTANCE hCoreDll;
UnregisterFunc1Proc procUndergisterFunc;
hCoreDll = LoadLibrary(_T("coredll.dll"));
ASSERT(hCoreDll);

procUndergisterFunc = (UnregisterFunc1Proc)GetProcAddress(hCoreDll,
_T("UnregisterFunc1"));

ASSERT(procUndergisterFunc);

int i=0x5b;
procUndergisterFunc(MOD_WIN, i);
RegisterHotKey(hWnd, i, MOD_WIN, i);


FreeLibrary(hCoreDll);

}

Just call this function at the start of your program. The value of variable
'i' I have found with Remote Spy by watching the messages that are sent when
theWin key is pressed. Maybe that value is different on your device.

Hope this helps,
Dusko




"Tony Selke" <TonySelke@discussions.microsoft.com> wrote in message
news:C6FD4C10-3185-4F4D-88E7-5FA94869D25A@microsoft.com...
> We are using C# with the CF v2.0 on WM 5.0. We have a requirement to trap
> hardware buttons to prevent the associated actions while a particular
> application has the focus. My team has had had no trouble doing this with
> the HardwareButton & HardwareKeys entities for "normal" buttons, however
> this
> process does not seem to work with the "Windows" button that (typically)
> brings up the "Start Menu" pop-up. We even tried a
> WindowSink:MessageWindow
> with a WndProc(Message) handler, but that doesn't get called by the button
> either. None of us has been successful in finding an answer. Is there
> something that will work?



Re: Trapping Hardware Buttons by TonySelke

TonySelke
Fri Jul 21 21:35:01 CDT 2006

Thank you for your reply. This does work in WM2003, however in WM5, it does
not capture the "Windows" button (which activates the Start menu). The C#
code that we used to validate this came from Microsoft's Input class in this
example:

http://msdn.microsoft.com/library/en-us/dnnetcomp/html/PInvokeLib.asp

In fact, this class captures all hardware buttons on the WM2003 emulator,
but the ONLY button it captures in the WM5.0 emulator is the calendar button.
The other buttons don't even get passed to the MessageWindow.WndProc()
function. All of the other buttons can be captured using the built-in CF2
classes, but the "Windows" button that opens the pop-up Start menu still
eludes us.

Tony

"dule" wrote:

> Hi,
> I have encountered the simillar problem on the Recon device and this is how
> I have solved it:
>
> typedef BOOL (__stdcall *UnregisterFunc1Proc)( UINT, UINT );
>
>
> void DisableWinKey (HWND hWnd)
> {
> HINSTANCE hCoreDll;
> UnregisterFunc1Proc procUndergisterFunc;
> hCoreDll = LoadLibrary(_T("coredll.dll"));
> ASSERT(hCoreDll);
>
> procUndergisterFunc = (UnregisterFunc1Proc)GetProcAddress(hCoreDll,
> _T("UnregisterFunc1"));
>
> ASSERT(procUndergisterFunc);
>
> int i=0x5b;
> procUndergisterFunc(MOD_WIN, i);
> RegisterHotKey(hWnd, i, MOD_WIN, i);
>
>
> FreeLibrary(hCoreDll);
>
> }
>
> Just call this function at the start of your program. The value of variable
> 'i' I have found with Remote Spy by watching the messages that are sent when
> theWin key is pressed. Maybe that value is different on your device.
>
> Hope this helps,
> Dusko
>
>
>
>
> "Tony Selke" <TonySelke@discussions.microsoft.com> wrote in message
> news:C6FD4C10-3185-4F4D-88E7-5FA94869D25A@microsoft.com...
> > We are using C# with the CF v2.0 on WM 5.0. We have a requirement to trap
> > hardware buttons to prevent the associated actions while a particular
> > application has the focus. My team has had had no trouble doing this with
> > the HardwareButton & HardwareKeys entities for "normal" buttons, however
> > this
> > process does not seem to work with the "Windows" button that (typically)
> > brings up the "Start Menu" pop-up. We even tried a
> > WindowSink:MessageWindow
> > with a WndProc(Message) handler, but that doesn't get called by the button
> > either. None of us has been successful in finding an answer. Is there
> > something that will work?
>
>
>

RE: Trapping Hardware Buttons by TonySelke

TonySelke
Fri Jul 21 21:58:01 CDT 2006

Perhaps we are asking the wrong question. We have found a good deal of code
all over that shows how you would do this in WM2003 and we have seen it work
in WM2003, but not in WM5.0. Unless the API has changed significantly, we
have to presume that the key code values for the hardware buttons are not the
same in the WM5.0 emulator as they are in the WM2003 emulator.

Can anyone help us figure out how to capture/view the key codes? We tried
hooking up Spy++ Remote, but while we can see the window list, we can't get
it to show any messages. Are we on the right track?

Tony

"Tony Selke" wrote:

> We are using C# with the CF v2.0 on WM 5.0. We have a requirement to trap
> hardware buttons to prevent the associated actions while a particular
> application has the focus. My team has had had no trouble doing this with
> the HardwareButton & HardwareKeys entities for "normal" buttons, however this
> process does not seem to work with the "Windows" button that (typically)
> brings up the "Start Menu" pop-up. We even tried a WindowSink:MessageWindow
> with a WndProc(Message) handler, but that doesn't get called by the button
> either. None of us has been successful in finding an answer. Is there
> something that will work?

Re: Trapping Hardware Buttons by Fabien

Fabien
Mon Jul 24 10:58:25 CDT 2006

Hi,

You can make a breakpoint in your WndProc function and watch the
message in parameters when you click on a hardware button... if the
keys are different you can strore your hardwarekey mapping in registry.

BR


Fabien Decret
Windows Embedded Consultant

ADENEO (ADESET)
http://www.adeneo.adetelgroup.com/




Tony Selke a =E9crit :

> Perhaps we are asking the wrong question. We have found a good deal of c=
ode
> all over that shows how you would do this in WM2003 and we have seen it w=
ork
> in WM2003, but not in WM5.0. Unless the API has changed significantly, we
> have to presume that the key code values for the hardware buttons are not=
the
> same in the WM5.0 emulator as they are in the WM2003 emulator.
>
> Can anyone help us figure out how to capture/view the key codes? We tried
> hooking up Spy++ Remote, but while we can see the window list, we can't g=
et
> it to show any messages. Are we on the right track?
>
> Tony
>
> "Tony Selke" wrote:
>
> > We are using C# with the CF v2.0 on WM 5.0. We have a requirement to t=
rap
> > hardware buttons to prevent the associated actions while a particular
> > application has the focus. My team has had had no trouble doing this w=
ith
> > the HardwareButton & HardwareKeys entities for "normal" buttons, howeve=
r this
> > process does not seem to work with the "Windows" button that (typically)
> > brings up the "Start Menu" pop-up. We even tried a WindowSink:MessageW=
indow
> > with a WndProc(Message) handler, but that doesn't get called by the but=
ton
> > either. None of us has been successful in finding an answer. Is there
> > something that will work?


Re: Trapping Hardware Buttons by TonySelke

TonySelke
Mon Jul 24 13:13:01 CDT 2006

Pressing the Window Start Menu key on the WM 5.0 Device Emulator does not
fire the WndProc function (though clicking the Calendar button does).

The reason for this, I think, is that the only buttons that will be handled
by the WndProc function are those that have been mapped through the use of
the UnregisterFunc1 an RegisterHotkey API funcitons. If I knew the key code
(or whichever number comes throught he WndProc as the Message.WParam) for the
button, I think I could make this work. I just don't know how to find that
value.

"Fabien" wrote:

> You can make a breakpoint in your WndProc function