📄 buttons.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 5310
ClientLeft = 2100
ClientTop = 1560
ClientWidth = 6615
LinkTopic = "Form1"
ScaleHeight = 5310
ScaleWidth = 6615
Begin VB.Label lblStatus
Alignment = 2 'Center
BackColor = &H00000000&
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 495
Left = 2280
TabIndex = 0
Top = 1440
Width = 3135
End
Begin VB.Image OverImage
Height = 555
Left = 2760
Picture = "Buttons.frx":0000
Top = 3840
Visible = 0 'False
Width = 1815
End
Begin VB.Image UpImage
Height = 555
Left = 2760
Picture = "Buttons.frx":162E
Top = 3120
Visible = 0 'False
Width = 1815
End
Begin VB.Image DownImage
Height = 555
Left = 2760
Picture = "Buttons.frx":2C5C
Top = 2400
Visible = 0 'False
Width = 1815
End
Begin VB.Image ButtonPicture1
Height = 555
Index = 3
Left = 240
Top = 1440
Width = 1575
End
Begin VB.Image ButtonPicture1
Height = 555
Index = 2
Left = 240
Top = 2280
Width = 1575
End
Begin VB.Image ButtonPicture1
Height = 555
Index = 1
Left = 240
Top = 3120
Width = 1575
End
Begin VB.Image ButtonPicture1
Height = 555
Index = 0
Left = 240
Top = 3960
Width = 1575
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'实现漂亮的按钮的例子
'其中有各种鼠标事件的判断和使用的技巧
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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -