| re: dragging an unknown image control
dear,
You can select images by using the index of the imagebox and also the mouse events.
like: see also attachment
form with command1 and image1 !!! with index=0 !!!!
use code=
===========================================
Option Explicit
Dim Xold As Integer
Dim Yold As Integer
Private Sub Form_Load()
Image1(0).BorderStyle = 1
Image1(0).Visible = False
Command1.Caption = "Add picture"
End Sub
Private Sub Command1_Click()
Load Image1(Image1.UBound + 1)
Image1(Image1.UBound).Visible = True
Image1(Image1.UBound).Top = 300
Image1(Image1.UBound).Left = 60
End Sub
Private Sub Image1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Xold = X
Yold = Y
End If
End Sub
Private Sub Image1_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
With Image1(Index)
If (X - Xold) < Width - .Left - 300 And (Y - Yold) < Height - .Top - 600 Then _
.Move .Left + (X - Xold), .Top + (Y - Yold)
End With
End If
End Sub
===========================================
|