【VB开源代码栏目提醒】:网学会员VB开源代码为您提供Ex13_8.frm参考,解决您在Ex13_8.frm学习中工作中的难题,参考学习。
VERSION 5.00
Begin VB.Form Ex13_8
Caption = "MouseDown事件的使用"
ClientHeight = 2505
ClientLeft = 60
ClientTop = 450
ClientWidth = 3360
LinkTopic = "Form1"
ScaleHeight = 2505
ScaleWidth = 3360
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "绘画"
Height = 375
Left = 2160
TabIndex = 3
Top = 240
Width = 855
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 375
Left = 2160
TabIndex = 2
Top = 1440
Width = 855
End
Begin VB.CommandButton Command1
Caption = "擦除"
Height = 375
Left = 2160
TabIndex = 1
Top = 840
Width = 855
End
Begin
VB.PictureBox Picture1
AutoSize = -1 'True
Height = 2160
Left = 120
Picture = "Ex13_8.frx":0000
ScaleHeight = 2100
ScaleWidth = 1710
TabIndex = 0
Top = 240
Width = 1770
End
End
Attribute VB_Name = "Ex13_8"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim mousestate As Integer
Dim isdraw As Boolean
Private Sub Command1_Click() '单击“擦除”按钮
mousestate = 1
End Sub
Private Sub Command2_Click() '退出
程序 End
End Sub
Private Sub Command3_Click()
mousestate = 2
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) '鼠标按下
If Button = 1 And mousestate = 1 Then '当按鼠标左 键时
Picture1.FillStyle = 0
Picture1.FillColor = RGB(255, 255, 255) '设置为白色
Picture1.ForeColor = RGB(255, 255, 255)
Picture1.Circle (X, Y), 50
ElseIf Button = 1 And mousestate = 2 Then '当绘画时
isdraw = True
Picture1.CurrentX = X
Picture1.CurrentY = Y
End If
Picture1.AutoRedraw = True '设置图片自动重画
End Sub
Private Sub Picture1_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Picture1.ForeColor = RGB(255, 255, 0) '颜色设置为黄色
If isdraw And mousestate = 2 Then Picture1.Line -(X, Y)
'开始画线
End Sub
Private Sub Picture1_MouseUp(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
If Button = 1 And mousestate = 2 Then isdraw = False
End Sub