Private Sub form1_mousedown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
mouseClickCounter = mouseClickCounter + 1
If mouseClickCounter = 1 Then
firstX = e.X
firstY = e.Y
messageToMe(firstX, firstY)
ElseIf mouseClickCounter = 2 Then
secondX = e.X
secondY = e.Y
Dim myGraphics As Graphics
Dim myPen As Pen
myPen = New Pen(Color:=Color.Black, Width:=2)
myGraphics = Graphics.FromHwnd(hwnd:=ActiveForm().Handle)
myGraphics.DrawLine(pen:=myPen, x1:=firstX, y1:=firstY, x2:=secondX, y2:=secondY)
messageToMe(secondX, secondY)
firstX = 0
firstY = 0
secondX = 0
secondY = 0
mouseClickCounter = 0
End If
End Sub
Public Sub messageToMe(ByVal X As Integer, ByVal Y As Integer)
MessageBox.Show("Hello!" & " " & mouseClickCounter & vbTab & "(" & X & ", " & Y & ")")
End Sub
End Class
No comments:
Post a Comment