• Advertisement
Sign in to follow this  

detecting when mouse outside client window

This topic is 4485 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, want to know when the mouse has moved outside of a window. Looks simple enough from looking at the msdn stuff. Just need to set up an event using one of these - TRACKMOUSEEVENT event; however, I can't make it compile: >error C2065: 'TRACKMOUSEEVENT' : undeclared identifier I am including as the docs say - >Header Declared in Winuser.h, include Windows.h what's missing?? Alternately, is there a better way to know when the mouse no longer hovers over the window? thanks, tony

Share this post


Link to post
Share on other sites
Advertisement
Hmm, I also get the "'TRACKMOUSEEVENT' : undeclared identifier" message. I'll look into it...

I believe what you're looking for is WM_MOUSELEAVE and WM_NCMOUSELEAVE.


EDIT:

Found a quick solution. Put #define _WIN32_WINNT 0x0400 at the very top of your source file. It must be before #include <windows.h>

BTW: What version of Windows are you runing?

[Edited by - xeddiex on October 10, 2005 6:01:55 AM]

Share this post


Link to post
Share on other sites
This is how I would do it, without windows messages:

RECT WindowRect = {0};
GetWindowRect(hWnd,&WindowRect);

Then just use GetCursorPos() and do all the checks for the mouse being inside or outside the window.

-Dev578

Share this post


Link to post
Share on other sites
Quote:
Original post by xeddiex

Found a quick solution. Put #define _WIN32_WINNT 0x0400 at the very top of your source file. It must be before #include <windows.h>

BTW: What version of Windows are you runing?


Thanks for looking into this! I still get the build error over here?

I am using Visual C++ .Net Standard, and WinXP Home.

Strange isnt it - this stuff must be very standard stuff...

Share this post


Link to post
Share on other sites
Quote:
Original post by dev578
This is how I would do it, without windows messages:

RECT WindowRect = {0};
GetWindowRect(hWnd,&WindowRect);

Then just use GetCursorPos() and do all the checks for the mouse being inside or outside the window.

-Dev578


Thanks, did it that way and all working now :)

tony

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement