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();
}
}
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();
}
}