<vi***********@ gmail.comwrote in message
news:20******** *************** ***********@s33 g2000pri.google groups.com...
>I tried this however however ClientRectangle has always x=0, and y=0
therefore this is not working correctly.
Do I have to write something else.
I tried this.bounds.con tains(ptCursor) , however that is also giving
wrong behaviour
The code I posted works fine for me. Did you remember to include the line
ptCursor = PointToClient(p tCursor);
to convert the cursor position to client coordinates?
I think that the reason why Bounds.Contains (ptCursor) won't work is that as
you move the mouse out of your client area onto the window border the
Mouseleave event fires. At this time the mouse is still within the Bounds
(which include the border) so the test for being outside the window fails.
When the mouse subsequently moves off the border to outside the window you
don't get another event because the mouse has already left the client area.
Some other things you could try are:
- Use the Win32 API function TrackMouseEvent and intercept the
WM_NCMOUSELEAVE message.
- Install a LowLevelMousePr oc hook.
Although I know how to do both of these from a pure Win32 API application
I'm not sure how to do either from within a WinForms application, but no
doubt there's someone else on this forum who could help. Good luck!
Chris Jobson