jmasterx
jmasterx

Reputation: 54173

TrackMouseEvent not working

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?

Upvotes: 12

Views: 4494

Answers (1)

Brian R. Bondy
Brian R. Bondy

Reputation: 347546

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.

Upvotes: 20

Related Questions