-
i´m trying to teach myself visual basic
using a vb6 professional edition
and tech yourself vb5 in 21 days
following the instructions for the drag&drop
i was annoyed:
starting the drag i get a wonderful frame,
but releasing the mousebutton does not (NOT)
drop the source into the frame,
but sets .left and .top to the mousepointers X and Y
i mean, por favor, if i go to the trouble of dragging
something , i want to drop it where i dragged it, which is where i want to drop it, which is why i dragged it there in the first place....
VB6 insists on dropping it where the mousepointer is...
i tried calculating the distance between .top and Y
to correct that, but somehow the .mousedown
is not triggered when i put code into the .DragDrop
HELP???
thanks in advance
katte
-
If you just want to move something around and have it stay where you leave it do something like:
Code:
Private lXOffset As Long, lYOffset As Long
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
lXOffset = X
lYOffset = Y
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then Picture1.Move Picture1.Left + X - lXOffset, Picture1.Top + Y - lYOffset
End Sub
-
thanks a bunch!
this works!
and a whole lot better than microsifts drag and drop.
how come this doesn´t?:
Dim lXOffset As Long, lYOffset As Long
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
lXOffset = X - Command1.Left
lYOffset = Y - Command1.Top
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then Command1.Move X - lXOffset, Y - lYOffset
End Sub
in fact, it produces TWO cmdbuttons that leave a trail...
but maybe i'm getting philosophical,
thanks for a fact that works!!!
katte