T
ThunderMusic
Hi,
I'm developping a form that renders differently when hovered and trigger
some processing when not hovered (leaved). The thing is, when I leave my
form and another form from my application is underneath, it works fine, but
if I leave my form and anything that is not from my application is
underneath, the Leave event does not fire until I hover something from my
application.
Here's my filtered code for the IMessageFilter (I did not pasted the
declarations, I just pasted my message proc) (at the end of the post)
Can someone tell me what's wrong with this code?
thanks
ThunderMusic
I'm developping a form that renders differently when hovered and trigger
some processing when not hovered (leaved). The thing is, when I leave my
form and another form from my application is underneath, it works fine, but
if I leave my form and anything that is not from my application is
underneath, the Leave event does not fire until I hover something from my
application.
Here's my filtered code for the IMessageFilter (I did not pasted the
declarations, I just pasted my message proc) (at the end of the post)
Can someone tell me what's wrong with this code?
thanks
ThunderMusic
Code:
public bool PreFilterMessage(ref Message m)
{
// Everything is done with WM_MOUSEMOVE
if (m.Msg == WM_MOUSEMOVE)
{
// look if the target is our control or contained by our control
Control ctrl = Control.FromHandle(m.HWnd);
if (ctrl != null && (ctrl == this._container ||
this._container.Contains(ctrl)))
{
// if this message WM_MOUSEMOVE is the first we get,
// we must trigger the MouseEnter event
if (!this._isEntered)
{
// trigger MouseEnter
this.OnMouseEnter();
this._isEntered = true;
}
// Get point (using target control coordinates)
Point pt = new Point(m.LParam.ToInt32());
// convert to controls coordinates if necessary
Point containerPoint;
if (ctrl != this._container)
containerPoint =
this._container.PointToClient(ctrl.PointToScreen(pt));
else
containerPoint = pt;
// Trigger MouseMove
this.OnMouseMove(new MouseEventArgs(MouseButtons.None, 0,
containerPoint.X, containerPoint.Y, 0));
}
else
{
// If the target is not a child and MouseLeaves has not been
triggered
// we must trigger MouseLeave
if (this._isEntered)
{
// Trigger MouseLeave
this.OnMouseLeave();
this._isEntered = false;
}
}
}
return false;
}