Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mouse Leave event on Windows Form [duplicate]

I've set the 'mouse leave' event on a windows form and I want to hide the form when the mouse leaves the visible area.

But here is where I am facing a problem. Even when I move the mouse to a button on the same form, it calls the 'mouse leave' event, which makes this form invisible.

It means I've got to prevent the event triggering when moving the mouse to the button. But how? Any other approach?

like image 686
Muhammad Ali Dildar Avatar asked Nov 14 '22 15:11

Muhammad Ali Dildar


1 Answers

There is no simple way to do it. One way could be to check all the controls inside the Form and if mouse is not over any of them this means mouse is outside the Form

Another way could be to check inside mouse leave event whether mouse is inside the window boundary or not

like image 152
Haris Hasan Avatar answered Nov 24 '22 00:11

Haris Hasan