views:

120

answers:

3

Hi

in Windows mobile, how to identify key press

or screen press ?

in any screen of my program and in any time, even if i not in any textbox focus ?

thank's in advance

A: 

Implement an IMessageFilter, then do Application.AddMessageFilter(myFilter);

In the message filter, look for WM_MOUSEUP messages (you'll have to search for that and define a constant for it). Then you can use Cursor.CurrentPosition to work out where the mouse was.

For keys, handle:

WM_KEYUP and WM_SYSKEYUP
Scott Langham
If only the CF supported it.
ctacke
A: 

Scott's on the right track. You need an IMessageFilter. Unfortunately the CF doesn't support them, nor does Application have an AddMessageFilter method.

The Smart Device Framework, however, does have an IMessageFilter, and its Application2 class does support AddMessageFilter.

ctacke
A: 

The .NET Compact Framework Team created a sample of how to subclass controls. You can use the WndProcHooker class to hook event handlers to WM_* events on a control.

http://blogs.msdn.com/netcfteam/archive/2005/05/20/420551.aspx

Jens Granlund