Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TrackMouseEvent not working

Tags:

c++

c

winapi

Basically, I call TrackMouseEvent in my WM_CREATE then I also called it again after a WM_MOUSELEAVE event, but this freezes up my program.

Where should I be sticking it?

like image 281
jmasterx Avatar asked May 22 '10 01:05

jmasterx


1 Answers

You need to call TrackMouseEvent when the mouse enters your control, and not when it leaves your control.

You can call TrackMouseEvent on the WM_MOUSEMOVE message. You don't need to call TrackMouseEvent every time WM_MOUSEMOVE is fired, just once up until you get another WM_MOUSELEAVE. After you get a WM_MOUSELEAVE you can set some flag so the next call to WM_MOUSEMOVE will know to call TrackMouseEvent again.

Basically you can emulate a fictional WM_MOUSEENTER by using WM_MOUSEMOVE and also having that flag set.

like image 63
Brian R. Bondy Avatar answered Sep 21 '22 15:09

Brian R. Bondy