Mein Code sieht derzeit so aus:
Es sind 2 Steuerelemete
1 Picturebox mit dem Namen Punkt index ist auf 0
1 CommandButton mit dem Namen cmdDim XPos As Single, YPos As Single, XP0 As Single, YP0 As Single, P1 As Single, _
XP2 As Single, YP2 As Single, P3 As Single, P4 As Single, XP5 As Single, YP5 _
As Single, XP7 As Single, YP7 As Single
Private Sub cmd_MouseDown(Button As Integer, Shift As Integer, X As Single, Y _
As Single)
XPos = X
YPos = Y
End Sub
Private Sub cmd_MouseMove(Button As Integer, Shift As Integer, X As Single, Y _
As Single)
If Button = vbLeftButton Then
cmd.Move cmd.Left + X - XPos, cmd.Top + Y - YPos
Call Load_punkt
End If
End Sub
Private Sub Form_Load()
Dim i As Integer
punkt(0).ZOrder 0
For i = 1 To 7
Load punkt(i)
punkt(i).Visible = True
punkt(i).ZOrder 0
Next i
Call Load_punkt
End Sub
Private Sub punkt_MouseDown(Index As Integer, Button As Integer, Shift As _
Integer, X As Single, Y As Single)
Select Case Index
Case 0
XP0 = X
YP0 = Y
Case 1
P1 = Y
Case 2
XP2 = X
YP2 = Y
Case 3
P3 = Y
Case 4
P4 = Y
Case 5
XP5 = X
YP5 = Y
Case 6
P6 = Y
Case 7
XP7 = X
YP7 = Y
End Select
End Sub
Private Sub punkt_MouseMove(Index As Integer, Button As Integer, Shift As _
Integer, X As Single, Y As Single)
Dim dtop As Integer
Dim dwidth As Integer
If Button = vbLeftButton Then
Select Case Index
Case 0
dtop = cmd.Top
punkt(Index).Move punkt(Index).Left + X - XP0, punkt(Index).Top + Y - YP0
cmd.Top = punkt(Index).Top
cmd.Height = cmd.Height + (dtop - cmd.Top)
cmd.Left = punkt(Index).Left
cmd.Width = (punkt(4).Left + 80 - cmd.Left)
Case 1
If Not punkt(Index).Top + 85 >= punkt(6).Top Then
punkt(Index).Move punkt(Index).Left, punkt(Index).Top + Y - P1
dtop = cmd.Top
cmd.Top = punkt(Index).Top
cmd.Height = cmd.Height + (dtop - cmd.Top)
End If
Case 2
dtop = cmd.Top
dwidth = cmd.Width
punkt(Index).Move punkt(Index).Left + X - XP0, punkt(Index).Top + Y - YP0
cmd.Top = punkt(Index).Top
cmd.Height = cmd.Height + (dtop - cmd.Top)
cmd.Width = punkt(Index).Left - cmd.Left
Case 3
punkt(Index).Move punkt(Index).Left + X - XP0
cmd.Left = punkt(Index).Left
cmd.Width = (punkt(4).Left + 80 - cmd.Left)
Case 4
punkt(Index).Move punkt(Index).Left + X - XP0
cmd.Width = punkt(Index).Left - cmd.Left
Case 5
punkt(Index).Move punkt(Index).Left + X - XP2, punkt(Index).Top + Y - YP2
cmd.Height = punkt(Index).Top - cmd.Top + 80
cmd.Left = punkt(Index).Left
cmd.Width = (punkt(4).Left + 80 - cmd.Left)
Case 6
punkt(Index).Move punkt(Index).Left, punkt(Index).Top + Y - P6
cmd.Height = punkt(Index).Top - cmd.Top + 80
Case 7
punkt(Index).Move punkt(Index).Left + X - XP7, punkt(Index).Top + Y - YP7
cmd.Height = punkt(Index).Top - cmd.Top + 80
cmd.Width = punkt(Index).Left - cmd.Left
End Select
End If
cmd.Refresh
End Sub
Sub Load_punkt()
punkt(0).Top = cmd.Top - 10
punkt(0).Left = cmd.Left - 10
punkt(1).Top = cmd.Top - 10
punkt(1).Left = cmd.Left + cmd.Width \ 2
punkt(2).Top = cmd.Top - 10
punkt(2).Left = cmd.Left + cmd.Width - 80
punkt(3).Top = (cmd.Top - 10) + (cmd.Height - 80) \ 2
punkt(3).Left = cmd.Left - 10
punkt(4).Top = (cmd.Top - 10) + (cmd.Height - 80) \ 2
punkt(4).Left = cmd.Left + cmd.Width - 80
punkt(5).Top = (cmd.Top - 10) + cmd.Height - 80
punkt(5).Left = cmd.Left - 10
punkt(6).Top = (cmd.Top - 10) + cmd.Height - 80
punkt(6).Left = cmd.Left + cmd.Width \ 2
punkt(7).Top = (cmd.Top - 10) + cmd.Height - 80
punkt(7).Left = cmd.Left + cmd.Width - 80
End Sub
Private Sub punkt_MouseUp(Index As Integer, Button As Integer, Shift As _
Integer, X As Single, Y As Single)
Call Load_punkt
End Sub |