Jump to content

  • Log In with Google      Sign In   
  • Create Account

MFC: Message for mouse leaving a window?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Starfall   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 December 1999 - 06:28 AM

(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


Sponsor:

#2 DaJudge   Members   -  Reputation: 138

Like
Likes
Like

Posted 15 December 1999 - 01:41 AM

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


#3 mordell   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 December 1999 - 06:28 AM

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).]





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS