I have a winform with some controls on it.
While the cursor is enters the form (form boundaries, this includes form's content) I want to trigger specific task.
When cursor leavs the form, i want to trigger another task.
Obviously seeting these events on form won't work: (because, for instance MouseLeave will bw triggered when i move from form itself to other control)
this.MouseEnter += (sender, e) =>
{
//do stuff
};
this.MouseLeave += (sender, e) =>
{
//do stuff
};
I laso tried IMessageFilter interface as appears in similar questions, but none gives me the needed result! The problem is to detect when mouse leave the form completely.
public bool PreFilterMessage(ref Message m)
{
switch (m.Msg)
{
case WM_MOUSEMOVE: //or other messages
bool z = myForm.Bounds.Contains(Cursor.Position); //This didn't help
}
eturn false;
}
There is also problem with detection within the form content (when i move between controls).
What am I missing?
update: i don't want to use timers!