Advertisement

MFC: Message for mouse leaving a window?

Started by December 15, 1999 12:28 PM
1 comment, last by Starfall 25 years ago
There is no such message. You will have to make a message hook to process every WM_MOUSEMOVE message and check if the mouse left your window. You can then define your own WM_MOVELEFT message and send it to your appication.
I never wrote something like that, but that's the idea I had when I read about that. In fact I tried it myself one or two times, but hooks get your system crashing that fast, you can't believe it. Not nice. Never tried it in WinNT, but Win98 crashes really easy when coding stuff like that...

CU,
Alex

------------------
Alexander Stockinger
Programmer

Alexander Stockinger
Programmer
(Yes, that icon means somebody is going to die if I don't get some help here. Probably me.)

I need to know when the mouse is leaving a window in an MFC program... I watch WM_MOUSEMOVE but the last I hear from that is the last point the mouse is at while still inside the window (often not very helpful). None of the other WM events I've tried seem to be able to tell me this... does anyone know how to do it? I'm thinking I could SetCapture the window, then watch WM_MOUSEMOVE for coordinates outside the window and ReleaseCapture, but it seems like a lot of work for something that should be so simple.

Please reply if you have any ideas.

Thanks!

Starfall

Advertisement
This was actually a pretty common task, so much so that I guess they decided to add support for it .

Check out API function TrackMouseEvent and the WM_MOUSELEAVE message.

HTH,

mordell

ps. This is only supported for WIN98/NT 4.0 or later.

[This message has been edited by mordell (edited December 15, 1999).]

__________________________________________

Yeah, sure... we are laughing WITH you ...

This topic is closed to new replies.

Advertisement