Re: Mouse leave for windows form which has some controls not firing as desired
- From: "Chris Jobson" <chris.jobson@xxxxxxxxxxxxxx>
- Date: Fri, 30 May 2008 09:21:49 +0100
<vidishasharma@xxxxxxxxx> wrote in message
news:20d82653-a0ed-4904-8965-e17ab641e9b5@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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.contains(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(ptCursor);
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 LowLevelMouseProc 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
.
- References:
- Mouse leave for windows form which has some controls not firing as desired
- From: vidishasharma
- Re: Mouse leave for windows form which has some controls not firing as desired
- From: Chris Jobson
- Re: Mouse leave for windows form which has some controls not firing as desired
- From: vidishasharma
- Mouse leave for windows form which has some controls not firing as desired
- Prev by Date: Re: Mouse leave for windows form which has some controls not firing as desired
- Next by Date: Re: Memory mapping
- Previous by thread: Re: Mouse leave for windows form which has some controls not firing as desired
- Next by thread: Excel Automation from C# (2005): COUPDAYBS
- Index(es):
Relevant Pages
|