Wondering how those hover controls are made. Like when you move your mouse over a edit box or button, it changes the look of it from like flat to sunken. How is this done?
Posted on 2003-03-11 17:30:10 by resistance_is_futile
This is how i did it:


fwKeys = wParam; // key flags
xPos = LOWORD(lParam); // horizontal position of cursor
yPos = HIWORD(lParam); // vertical position of cursor

The WM_MOUSEMOVE message is posted to a window when the cursor moves. If the mouse is not captured, the message is posted to the window that contains the cursor. Otherwise, the message is posted to the window that has captured the mouse.

write code for this message that just changes the look of the button,
for simplicity, if its a bitmap then change the bitmap to a suken looking one.
otherwise you could redraw the button itself to look sunken.
Posted on 2003-03-11 17:43:11 by Crunchi
ok so like get the mouse position and if its over ur button/control then change its style? hmm ok
Posted on 2003-03-11 17:44:54 by resistance_is_futile
no need to get the mouse position unless you want to use it. WM_MOUSEMOVE will only be sent to the window under the mouse IF the mouse is not already captured. just look for the message and change the style accordingly
Posted on 2003-03-11 17:47:00 by Crunchi
Check out this thread or do a search for MOUSEOVER, there are alot of threads dealing with this issue.

Posted on 2003-03-11 17:55:58 by donkey
okay cool thx...
Posted on 2003-03-11 18:28:47 by resistance_is_futile
I think there'd be a timer to check where's da mouse. return if mouse not moved since last timeslice. if it's outside the whole win, and there's some hovered butn, 'dehover' it, ret. find win child, if same as before=>ret. all to all 3 vars necessary
Posted on 2003-03-12 04:31:08 by Ultrano
You only have to do a ChildWindowFromPoint on a mouse move, if the window changes and it's the right one then you set the countdown timer, cancel it if the window changes agian. When the clock runs down to zero you change the image. This sort of thing is best done in a seperate thread.

Posted on 2003-03-12 04:36:33 by donkey
so, you haven't really tested it. Or not tested it enough. Imagine the user moves the mouse out of the window so fast, that no message is sent. Then, you'll have a hover button that does not fade-out always when it has to. I've actually made such hovers for a lot of time. Trust me, I know. There are about 5 ways to make hover buttons, and I told you the best one that does not involve 2 threads and constant refresh rate. ;)
Posted on 2003-03-12 12:00:25 by Ultrano
No, I haven't ever really used them or tested them, I guess I didn't think of all possible scenarios but I was just thinking outloud.

Posted on 2003-03-12 12:03:09 by donkey
I know :). Don't worry, I also started with theory like yours, if you practised, you'd also have found what to do and why.
Posted on 2003-03-12 12:13:16 by Ultrano