seeing the image while moving it

Icek
07-29-2003, 02:53 PM
How to move an Image (or a PictureBox) over a Form and see the image, not only its surrounding frame, during the move phase. Basically, my code looks as follows:


Private Xi As Single
Private Yi As Single

Private Sub Card_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Card(Index).Drag vbBeginDrag
Xi = X
Yi = Y
End If
End Sub

Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Source.Move X - Xi, Y - Yi
End Sub

Private Sub Card_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)
Source.Move Source.Left + X - Xi, Source.Top + Y - Yi
End Sub


The 'Card' is an Image (or a PictureBox) located in a control array. The code works fine, but I can't see the card face while I'm moving it.

blindwig
07-29-2003, 02:58 PM
Hmm, I haven't tried it yet, but have you tried setting the .autoredraw to true? Or put a .refresh statement in your dragdrop routine?

passel
07-29-2003, 04:33 PM
How to move an Image (or a PictureBox) over a Form and see the image, not only its surrounding frame, during the move phase. Basically, my code looks as follows:


Private Xi As Single
Private Yi As Single

Private Sub Card_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Card(Index).Drag vbBeginDrag
Xi = X
Yi = Y
End If
End Sub

Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Source.Move X - Xi, Y - Yi
End Sub

Private Sub Card_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)
Source.Move Source.Left + X - Xi, Source.Top + Y - Yi
End Sub


The 'Card' is an Image (or a PictureBox) located in a control array. The code works fine, but I can't see the card face while I'm moving it.


This is the way I do it.
The important thing to remember here, is that the ScaleMode of the
Picture Box must be the same as the ScaleMode of it's container, i.e. if
the picturebox is on the form, then the form and the picture box need
the same ScaleMode. I generally prefer a Scalemode of Pixels so
position matches 1 to 1 with the minimum (maximum?) resolution
of the monitor. But if they are both the same, twips, millimeters, or
whatever, the code below works great.

' Add to declarations area of Level Editor Form
Private XL As Single, YL As Single

'Paste these sub in
Private Sub Pic_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
XL = X: YL = Y
End Sub

Private Sub Pic_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static Busy As Boolean
If Not Busy Then
Busy = True
If Button = 1 Then
If X <> XL Or Y <> YL Then
pic.Left = pic.Left + (X - XL)
pic.Top = pic.Top + (Y - YL)
DoEvents
End If
End If
Busy = False
End If
End Sub

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum