-
I have a group of command buttons (lets say cmd(1 to 5))
My question - I want the backcolor to change when the mouse goes over it - no problem, I use the mousemove / mouseover event whatever it is.
BUT - I need the backcolor to reset after the mouse has finished passing over it, a sort of mouseover_finish event.
I could write 10,000 lines to check the axis / co-ordinataes of the mouse, but do I have any easier options please?
-
Hi,
On the mouse_move of the container of your cmdBouttons, reset the color back to its original. I don't know the layout of your program though...
Steph
-
Try setting the color back on other mouse over events:
so:
Code:
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
recolorall
Command1.BackColor = vbRed
End Sub
sub recolorall()
Command1.BackColor = &H8000000F
etc
end sub
note: you will have to change the graphical property to true
place recolorall command in all of the controls and the forms mousemove event.
Rob
-
Its a shame that MS didn't invent a Mouse_Out event for all of the common controls, its quite a glaring omission in my opinion!
Anyway, you could set up a timer to call...
Code:
Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
...every 10th of a second or so, and if the coords are outside any of the buttons then you can change the colours accordingly. API functions such as the one above execute very quickly and should not make a dent on the performance of your application.
Furthermore, it should take considerably less than 10,000 lines of code! :)
-
I agree with Steph, just put code in the mouseover event of the container i.e. the form that the controls have been placed on. Easy. So when the mouse moves over a control, it changes colour or whatever, then when it moves over the form (but not over a control) it does whatever you have coded in the form's mousemove event.
-
I agree with JamesM and Steph, that appears to be the simplest solution.
-
<?>
Of course if your buttons are touching in a line then the container idea won't work under all circumstances so you would want your opposite in the container or any other control you might move over to get to the container.