Hello all,
Attached is a quick demo to do button rollover using a method which I haven't seen elsewhere: watching the WM_SETCURSOR message. Other ways of handling this that I've seen involve subclassing windows for the WM_MOUSEMOVE message. I find this is much simpler, and perhaps more flexible.
--Chorus
Attached is a quick demo to do button rollover using a method which I haven't seen elsewhere: watching the WM_SETCURSOR message. Other ways of handling this that I've seen involve subclassing windows for the WM_MOUSEMOVE message. I find this is much simpler, and perhaps more flexible.
--Chorus
Chorus, nice.
You might want to find a better way to detect when the mouse leaves the button area, though. I was able to get the button to change to blue and stay blue by moving the mouse cursor outside of the button area really fast. I could also do the same thing by resizing the window.
If you don't mind sacrificing Win95 compatibility you could use TrackMouseEvent to get WM_MOUSELEAVE messages.
You might want to find a better way to detect when the mouse leaves the button area, though. I was able to get the button to change to blue and stay blue by moving the mouse cursor outside of the button area really fast. I could also do the same thing by resizing the window.
If you don't mind sacrificing Win95 compatibility you could use TrackMouseEvent to get WM_MOUSELEAVE messages.
iblis, Thank you.
Win95 compatibility is my primary reason for not using TrackMouseEvent. I also want to avoid subclassing and hooks this way. Since the WM_SETCURSOR message gets passed up to a window's parent by DefWindowProc it works very simply -- you just have to handle it in your Application Main Window.
As for the button staying highlighted, perhaps the most straightforward solution is to install a timer and a corresponding proc.
Ex.
--Chorus
Win95 compatibility is my primary reason for not using TrackMouseEvent. I also want to avoid subclassing and hooks this way. Since the WM_SETCURSOR message gets passed up to a window's parent by DefWindowProc it works very simply -- you just have to handle it in your Application Main Window.
As for the button staying highlighted, perhaps the most straightforward solution is to install a timer and a corresponding proc.
Ex.
TimerProc PROC hWin,uMsg,idEvent,cTime:DWORD
cmp ButtonRollover,NULL
je @@DoNothing
invoke WindowFromPoint,msg.pt.x,msg.pt.y
cmp eax,ButtonRollover
je @@DoNothing
@@ClearButton: mov eax,ButtonRollover
mov ButtonRollover,NULL
invoke InvalidateRect,eax,NULL,TRUE
@@DoNothing: ret
TimerProc ENDP
--Chorus
Nice work!
I could have used this with my Custom Control Tuturial....
:alright:
NaN
I could have used this with my Custom Control Tuturial....
:alright:
NaN
If u enter a green square, and then mantain the left mouse button clicked, and go outside the window, the square gets blue until u enter again in the window.
greets.
greets.