Re: Mouse leave for windows form which has some controls not firing as desired



<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


.



Relevant Pages

  • Re: Mouse leave for windows form which has some controls not firing as desired
    ... you move the mouse out of your client area onto the window border the ... so the test for being outside the window fails. ... don't get another event because the mouse has already left the client area. ... Although I know how to do both of these from a pure Win32 API application ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Mouse leave for windows form which has some controls not firing as desired
    ... you move the mouse out of your client area onto the window border the ... so the test for being outside the window fails. ... don't get another event because the mouse has already left the client area. ... Although I know how to do both of these from a pure Win32 API application ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: how to draw my own style of window
    ... i use WIN32 API, not MFC ... That won't prevent you from removing the decorations and drawing custom ... decorations inside the client area (and make a child window to represent the ...
    (microsoft.public.win32.programmer.ui)
  • Borderless Dialog as Child Window
    ... i need to create a Dialog without a border in order to embed it into the ... client area of the main window. ... Please post some link or sample code 4 me. ...
    (microsoft.public.win32.programmer.ui)
  • Re: Form size ???
    ... It's a single border so I assume we are looking ... Make the height of the panel the multiple of 4 pixels that is less than ... or equal to the height of the client area ... The control in question is a user control ...
    (microsoft.public.dotnet.languages.vb)