If your platform uses the aygshell component, which is probably does if it
uses the tap-n-hold circle, then you can use SHRecognizeGesture from your
LBUTTONDOWN handler which you can P/Invoke using:-
[DllImport("aygshell.dll", SetLastError=true)]
public static extern int SHRecognizeGesture(ref SHRGINFO shrgi);
public const int GN_CONTEXTMENU = 1000;
public struct SHRGINFO
{
public int cbSize;
public IntPtr hwndClient;
public int ptDownX;
public int ptDownY;
public SHRGFlags dwFlags;
}
public enum SHRGFlags: int
{
RETURNCMD =0x00000001,
NOTIFYPARENT =0x00000002,
LONGDELAY =0x00000008,
NOANIMATION =0x00000010,
}
Then use something like this within your WM_LBUTTONDOWN handler:-
//get screen co-ordinates
Point p = new Point(m.LParam.ToInt32() & 0x0000ffff, (m.LParam.ToInt32() &
0x0fff0000) >> 16);
SHRGINFO inf = new SHRGINFO();
inf.cbSize = Marshal.SizeOf(inf);
inf.hwndClient = mhwnd;
inf.ptDownX = p.X;
inf.ptDownY = p.Y;
inf.dwFlags = SHRGFlags.RETURNCMD;
if(SHRecognizeGesture(ref inf)==GN_CONTEXTMENU)
{
contextMenu1.Show(this, Control.MousePosition);
}
I don't have an applicable device to test on but I tried it on Pocket PC as
an alternative to setting a ContextMenu directly and it appears to work.
Used in this way SHRecognizeGesture will block until either the tap-n-hold
completes in which case it returns GN_CONTEXTMENU or if interrupted it will
return 0. By changing the flags you can instead opt to have the method send
a WM_NOTIFY to your window containing the GN_CONTEXTMENU value which you can
catch separately.
Peter
--
Peter Foot
Windows Embedded MVP
www.inthehand.com |
www.opennetcf.org
Drasko said:
Thanks Chris.
Using ApplicationEx I added MouseUp, MouseDown and MouseMove events to my
listview control (it's great!). Also I add TapAndHold event. Problem is to
distinguish "tap" from "tapandhold" because after single "tap" MouseDown
event fires but MouseUp not (I cannot catch WM_LBUTTONUP?). So when
"tap-and-hold" timer expires, I have to detect if button is still pressed
and I tried to use Control.Capture property, but it sometimes work
sometimes
not. Obviously I am missing something. Can you help!?
Thanks
Drasko
up
and