1,486
社区成员
发帖
与我相关
我的任务
分享
Dim gdi As GDIPlusClass
Dim is_exit As Boolean
Dim is_draw As Boolean
Dim mouse_x As Long
Dim mousy_y As Long
Private Sub Form_Load()
Set gdi = New GDIPlusClass
gdi.Create Picture1.Width, Picture1.Height
gdi.bgColor = &H0
is_draw = True
is_exit = False
Do
DoEvents
DrawImage
Loop While Not is_exit
gdi.Close
Set gdi = Nothing
End Sub
'// 绘图过程
Private Sub DrawImage()
If Not is_draw Then
Exit Function
End If
gdi.Cls
gdi.DrawLine mouse_x - 20, mousy_y - 20, mouse_x + 20, mousy_y + 20, &HFF, B
is_draw = False
Refresh
End Sub
'// 刷新过程
Private Sub Refresh()
gdi.DrawImage Picture1.hDC, 0, 0, gdi.iWidth, gdi.iHeight, 0, 0, gdi.iWidth, gdi.iHeight, vbSrcCopy
End Sub
Private Sub Picture1_Resize()
gdi.ZoomSize Picture1.Width, Picture1.Height
is_draw = True
DrawImage
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X <> mouse_x Or Y <> mousy_y Then
mouse_x = X
mousy_y = Y
is_draw = True
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
If X > 0 And X < 40 And Y > 0 And Y < 40 Then
is_exit = True
End If
End If
End Sub
Private Sub Picture1_Paint()
Refresh
End Sub
不用去研究那个GDIPlusClass类,这个是我自己写的一个类,系统没有的,这里用只是方便解释程序而已。