Hallo Schmacko,
probier mal dieses:
'Benötigt werden: 1 Label, 1 Picturebox mit Index = 0
Option Explicit
Private XD!, YD!, TwX!, TwY!
Private Sub Form_Load()
Dim i%, Anf As Object
Me.ScaleMode = vbPixels
Me.BackColor = vbButtonFace
TwX = Screen.TwipsPerPixelX
TwY = Screen.TwipsPerPixelY
With Label1
.Caption = ""
.Appearance = 0
.BorderStyle = vbBSSolid
.BackStyle = vbTransparent
.MousePointer = vbSizeAll
End With
For i = 0 To 3
Set Anf = Picture1(i)
If i > 0 Then Load Anf
With Anf
.ScaleMode = vbPixels
.BorderStyle = vbBSNone
.Move 0, 0, 7, 7
.BackColor = vbRed
.AutoRedraw = True
.MousePointer = IIf(i = 0 Or i = 3, vbSizeNS, vbSizeWE)
End With
Anf.Line (0, 0)-(6, 6), vbWhite, B
Next i
Call SetzeAnf
End Sub
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, _
Y As Single)
Dim i%
XD = X
YD = Y
For i = 0 To 3
Picture1(i).Visible = False
Next i
Label1.ZOrder vbBringToFront
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, _
Y As Single)
If Button = vbLeftButton Then
With Label1
.Move .Left + (X - XD) / TwX, .Top + (Y - YD) / TwY
End With
End If
End Sub
Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y _
As Single)
Call SetzeAnf
End Sub
Private Sub Picture1_MouseDown(Index As Integer, Button As Integer, Shift As _
Integer, X As Single, Y As Single)
Dim i%
XD = X
YD = Y
For i = 0 To 3
Picture1(i).Visible = False
Next i
Picture1(Index).ZOrder vbBringToFront
End Sub
Private Sub Picture1_MouseMove(Index As Integer, Button As Integer, Shift As _
Integer, X As Single, Y As Single)
Dim K1!, K2!, K3!, K4!, XP!, YP!
If Button = vbLeftButton Then
With Label1
K1 = .Left
K2 = .Top
K3 = .Width
K4 = .Height
XP = K1
YP = K2
With Picture1(Index)
.Move .Left - XD + X, .Top - YD + Y
Select Case Index
Case 0
K2 = .Top + .Height
K4 = YP - K2 + K4
Case 1
K1 = .Left + .Width
K3 = XP - K1 + K3
Case 2
K3 = .Left - K1
Case 3
K4 = .Top - K2
End Select
End With
.Move K1, K2, IIf(K3 < 1, 1, K3), IIf(K4 < 1, 1, K4)
End With
End If
End Sub
Private Sub Picture1_MouseUp(Index As Integer, Button As Integer, Shift As _
Integer, X As Single, Y As Single)
Call SetzeAnf
End Sub
Private Sub SetzeAnf()
Dim i%, XP!, YP!, K1!, K2!, K3!, K4!
With Label1
K1 = .Left
K2 = .Top
K3 = .Width
K4 = .Height
.ZOrder vbBringToFront
End With
For i = 0 To 3
With Picture1(i)
Select Case i
Case 0
XP = (K3 - .Width) \ 2
YP = -.Height
Case 1
XP = -.Width
YP = (K4 - .Height) \ 2
Case 2
XP = K3
YP = (K4 - .Height) \ 2
Case 3
XP = (K3 - .Width) \ 2
YP = K4
End Select
.Move K1 + XP, K2 + YP
.ZOrder vbBringToFront
.Visible = True
End With
Next i
End Sub Gruss,
Zardoz |