Jump to content
  • Advertisement
Sign in to follow this  
PokerMike

TrackMouseEvent and WM_MOUSEHOVER

This topic is 4142 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

Hey all, I have the following code called everytime a WM_MOUSEMOVE is evoked. I have also tried to locate this code in other places, yet I never receive a single WM_MOUSEHOVER event. Is there something that I am missing? Thanks! TRACKMOUSEEVENT tme; tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.dwFlags = TME_HOVER; tme.dwHoverTime = 100; tme.hwndTrack = hwnd; TrackMouseEvent(&tme); -Mike

Share this post


Link to post
Share on other sites
Advertisement
no, you aren't missing a thing. it should work perfectly the way you have it. i just tested it right now and it works fine for me, just as it should. all i did was inject this code in my window proc:


case WM_MOUSEMOVE:
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_HOVER;
tme.dwHoverTime = 100;
tme.hwndTrack = hWnd;
TrackMouseEvent(&tme);
break;
case WM_MOUSEHOVER:
SetWindowText(hWnd, "WM_MOUSEHOVER!");
break;


practically same code as yours. i move the mouse and my caption changes. since TrackMouseEvent is only defined with both _WIN32_WINNT and WINVER #defined to 0x0501, you probably already have that in your code... so i don't know what's wrong. maybe you're just not detecting your WM_MOUSEHOVER correctly? try a simple caption change, see what happens. if this is for a control or child window, make sure that the parent window or any other window doesn't have the capture, as that would prevent the child window from receiving any WM_MOUSEMOVEs. also check to make sure that your TRACKMOUSEEVENT section in WM_MOUSEMOVE is executing (is it in an if statement that's never executing?).

also note that your mouse has to hover in the window the entire 100 ms or else WM_MOUSEHOVER won't fire. just flying past the window with the mouse (a quick enter and exit) won't do.

Share this post


Link to post
Share on other sites
Right. I finally found it. Apparently if you process WM_ACTIVATE you have to send it to DefWindowProc. Thanks for pointing out that this code actually does work.

-Mike

Share this post


Link to post
Share on other sites
Actually, you're suppose to return 0. I highly recommend checking MSDN for each event you handle in your winproc anyways to make sure you have it right.

http://msdn2.microsoft.com/en-us/library/ms646274.aspx <-- WM_ACTIVATE, states in return type that if you process it, return 0.

Edit: Sorry that sounded rude and it wasn't my intent. I was trying to say I refer to MSDN for each new event I handle to make sure I'm doing it right and that I would recommend it to anyone else.

[Edited by - Mike2343 on June 14, 2007 10:30:25 AM]

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!