SHRecognizeGesture avoids the MouseUp event

  • Thread starter Thread starter Jon Abaunza
  • Start date Start date
J

Jon Abaunza

Hallo I am developing my custom control that would have self managed
tooltips. In order to identify when to show the toolTip I P/Invoke
SHRecognizeGesture. The problem is that it generates an strange
behaviour. Normally if I would not invoke this method the normal
behaviour would be:
-Make Mouse Down ------> Mouse Down event of the control is fired
-Move the Stylus out of the Control
- Make MouseUp -------> Mouse Up event of the control is fired

But if I Invoke the SHRecognizeGesture the MouseUp message is never
received and therefore the event is not rised.
Does someone know why this is happening?
Thanks in advance
Jon

Note: If instead of doing the mouseUp out of my Control, I do it on it,
the mouse up event is rised perfectly.


MouseDown Code
---------------------------------

SHRGINFO shrginfo = new SHRGINFO();
shrginfo.cbSize = (uint)Marshal.SizeOf(shrginfo);
shrginfo.hwndClient = m_oMenuBar.Handle;
shrginfo.x = Control.MousePosition.X;
shrginfo.y = Control.MousePosition.Y;
shrginfo.dwFlags = NativeMethods.SHRG_NOANIMATION |
NativeMethods.SHRG_RETURNCMD;

//I call the tap and hold ring (without showing it)
uint nGestureAnswer = NativeMethods.SHRecognizeGesture(shrginfo);
if (nGestureAnswer == NativeMethods.GN_CONTEXTMENU)
{
//now i will check that they didn't move out of the Button during
the recognize gesture
int xPosRelative = e.MousePosition.X + shrginfo.x -
Control.MousePosition.X;
int yPosRelative = e.MousePosition.Y + shrginfo.y -
Control.MousePosition.Y;
if (e.ButtonBounds.Contains(new System.Drawing.Point(xPosRelative,
yPosRelative)))
{

m_oPopUpText.Text =
m_oTopMenuEntryCollection[e.ButtonIndex].Description;
int xPos = e.ButtonBounds.X;
if (xPos + m_oPopUpText.Width > this.Width)
{
xPos = this.Width - m_oPopUpText.Width;
}
int yPos = m_oMenuBar.Top - m_oPopUpText.Height;
m_oPopUpText.Top = 5;
m_oPopUpText.Left = xPos;
m_oPopUpText.Show();
}
}
 
Hallo Alex,

In the end I decided to implement it with a timer. Because if they
moved a little while the SHRecognizeGesture was running, the method
returned a false gesture even if they didn't move out of the area that
should rise the tooltip.
But I am interested on knowing why it didn't work what I intended.
In my previous implementation i didn't set the Control.Capture to any
value. What would have been the difference?

Thank you very much for answering,

Jon
 
The difference it would have made is that setting Capture to true would have
made sure your control receives all mouse events including MouseUp even if
the stylus is moved out of it
 
Back
Top