Can you use the MouseMove event for a control array so that only one button's backcolor will change? As of now, every button changes color when the MouseMove event is fired. Thanks
Printable View
Can you use the MouseMove event for a control array so that only one button's backcolor will change? As of now, every button changes color when the MouseMove event is fired. Thanks
Command1(Index).BackColor = Something.
You have to specify which button by Index which is given to you in the event.
VB Code:
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As Long Private Declare Function GetCapture Lib "user32" () As Long Private Sub cmdTest_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single) If Index = 1 Then If (X < 0) Or (Y < 0) Or (X > cmdTest(Index).Width) Or (Y > cmdTest(Index).Height) Then ' the MOUSELEAVE pseudo-event ReleaseCapture cmdTest(Index).BackColor = &H8000000F ElseIf GetCapture() <> cmdTest(Index).hwnd Then SetCapture cmdTest(Index).hwnd cmdTest(Index).BackColor = vbCyan End If End If End Sub