|
Public Class Form1
Private p As Point
Protected EquipmentSelections() As Button
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
EquipmentSelections = _
New Button() {Button1, Button2, Button3, Button4}
For Each Button As Button In EquipmentSelections
AddHandler Button.MouseDown, AddressOf Koordinaten
AddHandler Button.MouseMove, AddressOf Bewegung
AddHandler Button.Click, AddressOf Button_Click
Next
End Sub
Private Sub Bewegung(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs)
For Each Button As Button In EquipmentSelections
If e.Button = Windows.Forms.MouseButtons.Left Then
If Button Is sender Then
Button.Location = _
New Point(Button.Location.X + e.X - p.X, _
Button.Location.Y + e.Y - p.Y)
End If
End If
Next
End Sub
Private Sub Koordinaten(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs)
p.X = e.X
p.Y = e.Y
End Sub
Private Sub Button_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs)
If sender.name = "Button4" Then
If MessageBox.Show("Beenden?", "Beenden", _
MessageBoxButtons.YesNo, _
MessageBoxIcon.Question) = _
Windows.Forms.DialogResult.Yes Then
Me.Close()
Else
MessageBox.Show(sender.name, sender.name, _
MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Else
MessageBox.Show(sender.name, sender.name, _
MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
End Class
|
|