Option Explicit
'--------------------------------------------
'BUTTONS2.VBP August 24, 1999
'Burt Abreu habreu@VBExplorer.com
'
'This project was written to answer a
'FAQ - How to create rollover effects.
'Thanks go to Rod Stephens who cleaned
'up and tweaked the code.
'
'--------------------------------------------
Dim MouseOver
Dim MousePress
Dim NewIndex
Private Sub ButtonPicture1_MouseDown(Index As Integer, _
Button As Integer, Shift As Integer, X As Single, Y As Single)
If MousePress Then Exit Sub
ButtonPicture1(Index).Picture = DownImage.Picture
lblStatus.Caption = "Mouse Down"
MousePress = True
End Sub
Private Sub ButtonPicture1_MouseMove(Index As Integer, _
Button As Integer, Shift As Integer, X As Single, Y As Single)
If MouseOver Then Exit Sub
ButtonPicture1(Index).Picture = OverImage.Picture
lblStatus.Caption = "Mouse Over - Button"
NewIndex = Index
MouseOver = True
End Sub
Private Sub ButtonPicture1_MouseUp(Index As Integer, _
Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not MousePress Then Exit Sub
ButtonPicture1(Index).Picture = UpImage.Picture
lblStatus.Caption = "Mouse Up"
MousePress = False
End Sub
Private Sub Form_Load()
Dim i As Integer
lblStatus.Caption = "Ready?"
For i = ButtonPicture1.LBound To ButtonPicture1.UBound
ButtonPicture1(i).Picture = UpImage.Picture
Next i
End Sub
Private Sub Form_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
If Not MouseOver Then Exit Sub
lblStatus.Caption = "Mouse Over - Form"
MouseOver = False
MousePress = False
ButtonPicture1(NewIndex).Picture = UpImage.Picture
End Sub
Downloads
In IE right-click and select 'Save Target As...' or in Netscape
right-click and select 'Save Link As...'
View Plain Text
Download Demo Project
Not Available