|
-
Feb 4th, 2001, 03:54 PM
#1
Thread Starter
Lively Member
***This message was originally posted in the general Q&A section but I was having no luck - hopefully I'll get more help here...***
Can someone please help me? I have a form with two picture boxes, picDragDrop1 and picDragDrop2. I have an image in both (the same image) but in picDragDrop1 it is visible and in picDragDrop2 it is not visible.
I am trying to code the dragdrop and dragover procedures so that:
1) when the picture is dragged out of the first picture box and is dropped on the form, it appears to "snap" back into the first picture box
2) when the picture is dragged out of the first picture box and is dropped onto the second picture box, it appears in the second picture box but vanishes from the first (i.e. as if it "moved")
3) when the picture is dragged within the first picture box or is dragged around anywhere on the form but then dropped back onto the first picture box, it reappears in the first picture box as it originally was.
I am having trouble only with this last part (part 3). When I drop it back onto the first picture box it vanishes completely. Why is this? Here is the code I have so far:
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
picDragDrop1.Visible = True
End Sub
Private Sub picDragDrop1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
picDragDrop1.Visible = False
End Sub
Private Sub picDragDrop2_DragDrop(Source As Control, X As Single, Y As Single)
picDragDrop2.Picture = Source.Picture
End Sub
-
Feb 5th, 2001, 08:16 PM
#2
Good Ol' Platypus
Try this:
Code:
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
picDragDrop1.Visible = True
End Sub
Private Sub picDragDrop1_DragDrop(Source As Control, X As Single, Y As Single)
If source=picDragDrop2 then
picDragDrop2.visible = False
picDragDrop1.visible = True
end if
End Sub
Private Sub picDragDrop2_DragDrop(Source As Control, X As Single, Y As Single)
If source=picDragDrop1 then
picDragDrop2.visible = True
picDragDrop1.visible = False
end if
End Sub
The reason that it didnt work (i think) is because you had dragOVER instead of dragDROP
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Feb 6th, 2001, 07:18 PM
#3
Good Ol' Platypus
Sorry, that probably wont work. I didn't understand the question at first. You'll need to tweak it.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Feb 20th, 2001, 01:20 PM
#4
Thread Starter
Lively Member
Perfect Solution!
Hi sastraxi,
I'm sorry, but your suggestion did not work the way I wanted it.
Shame on all of you who could not help me properly with this! That includes you programmers in the General VB Questions section too!
You will all, no doubt, appreciate the fact that I have successfully managed to figure out the answer to my problem on my own! Here's how I did it (I had to use the DragDrop event procedures of the two frame controls containg the pictures):
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
If X < Me.Width / 2 Then
picDragDrop1.Visible = True
Else
picDragDrop2.Visible = True
End If
End Sub
Private Sub fraPic1_DragDrop(Source As Control, X As Single, Y As Single)
picDragDrop1.Visible = True
End Sub
Private Sub fraPic2_DragDrop(Source As Control, X As Single, Y As Single)
picDragDrop2.Visible = True
End Sub
Private Sub picDragDrop1_DragDrop(Source As Control, X As Single, Y As Single)
picDragDrop2.Visible = True
End Sub
Private Sub picDragDrop1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
picDragDrop1.Visible = False
End Sub
Private Sub picDragDrop2_DragDrop(Source As Control, X As Single, Y As Single)
picDragDrop2.Visible = True
End Sub
Private Sub picDragDrop2_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
picDragDrop2.Visible = False
End Sub
Hope this might help someone else who was having the same problem!
-
Feb 20th, 2001, 04:57 PM
#5
Good Ol' Platypus
Shame on me too? Gosh, gulliver, I'm hurt! 
-just kidding
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Feb 20th, 2001, 04:58 PM
#6
Good Ol' Platypus
Oh yeah, and gulliver, this is for you:
:P
- sorry I couldn't help you, but I'm not that good on the subject either. Cheers!
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Feb 20th, 2001, 05:36 PM
#7
Thread Starter
Lively Member
No hard feelings?
Thanks for trying sastrxi. No hard feelings OK?
:-)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|