The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Mr Earl on March 17, 2006, 12:40:45 PM

Title: TrackMouseEvent
Post by: Mr Earl on March 17, 2006, 12:40:45 PM
Why doesn't this code work?

LOCAL track:TRACKMOUSEEVENT

.elseif iMsg==WM_MOUSEHOVER
PrintText"HOVER"

.elseif iMsg==WM_MOUSELEAVE
PrintText"LEAVE"

.elseif iMsg==WM_MOUSEMOVE
mov track.cbSize,sizeof track
mov track.dwFlags,TME_LEAVE or TME_HOVER
m2m track.hwndTrack,hFind
mov track.dwHoverTime,400
invoke TrackMouseEvent,addr track


hFind is a dialog PUSHBUTTON.  I can get a ToolTip to work for it, but I never get a WM_MOUSEHOVER.
DEBUG is turned on
Title: Re: TrackMouseEvent
Post by: donkey on March 18, 2006, 05:03:15 AM
Make sure that you are not placing the test for the messages in your main window or dialog proc, they have to be in the proc for the control itself. If it is a button then subclass it and use the subclassing procedure...

To sublcass the button (in your WM_INITDIALOG handler or once it is created)
invoke SetWindowLong,hFind,GWL_WNDPROC,offset BtnSubClass
mov pButtonProc,eax


Button subclass procedure
BtnSubClass PROC hwnd:DWORD, iMsg:DWORD, wParam:DWORD, lParam:DWORD
LOCAL track:TRACKMOUSEEVENT

.if iMsg==WM_MOUSEHOVER
PrintText"HOVER"

.elseif iMsg==WM_MOUSELEAVE
PrintText"LEAVE"

.elseif iMsg==WM_MOUSEMOVE
mov track.cbSize,sizeof TRACKMOUSEEVENT
mov track.dwFlags,TME_LEAVE or TME_HOVER
m2m track.hwndTrack,hwnd
mov track.dwHoverTime,400
invoke TrackMouseEvent,addr track

.endif
invoke CallWindowProc,pButtonProc,hwnd,iMsg,wParam,lParam
RET
ENDF
Title: Re: TrackMouseEvent
Post by: Mr Earl on March 18, 2006, 09:41:44 AM
Thank you.  That solved the problem.