|
Этот код покажет, как изменяется цвет кнопки при передвижении над ней курсора.
Добавьте 1 Command Button. Установите свойство Style кнопки в 1 - Graphical. Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As
Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Public Sub sysControlHighLight(ctl As Control, X As Single, Y As Single, OriginalBackColor
As Long, NewBackColor As Long)
Dim HitTest As Long
On Error Resume Next
HitTest = ctl.hwnd
If Err.Number <> 0 Then Exit Sub
With ctl
If (X > .Width) Or (Y > .Height) Then
ReleaseCapture
.BackColor = OriginalBackColor
Else
SetCapture .hwnd
.BackColor = NewBackColor
End If
End With
On Error GoTo 0
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As
Single)
'замените 'vbGreen' и 'vbRed' на нужный вам цвет
sysControlHighLight Command1, X, Y, vbGreen, vbRed
End Sub
Private Sub Form_Load()
'замените на такой же цвет, как и предыдущий 'vbGreen'
Command1.BackColor = vbGreen
End Sub
|
|