View Full Version : Visual Basic - Drag and Drop
I am working on a game mimicking score simulator where you can drag around robots and bins and get scores, but i'm haveing trouble with the drag and drop part.
When I only set the forum to allow movement for one object
Source.Move X, Y
Then things work fine, but when I set the forum to allow movement for two or more objects
Source1.Move X, Y
Source2.Move X, Y
Then when I drag either object Source1 is in the drop positon and Source2 is nowhere to be found.
I'm clueless, and can't find a tutorial or forum with the answer, PLEASE HELP!!!!
01-05-2003, 10:56 PM
on a form not forum right? Are you setting both objects to drag mode=automatic?
01-05-2003, 11:14 PM
i am considering making a web based scoring simulator for everyone. Tell me how ur sim goes. Can u post it when ur finished┐
This is my program, except for the positioning junk, it dosent work in vbManual or vbAutomatic.
Private xoffset As Integer
Private yoffset As Integer
Private Sub ba_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
xoffset = X
yoffset = Y
Private Sub bb_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
xoffset = X
yoffset = Y
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
bb.Move (X - xoffset), (Y - yoffset)
ba.Move (X - xoffset), (Y - yoffset)
ya, if i finish this, i'll pass it out to whoever wants it.
01-05-2003, 11:52 PM
What I'd like to see is a version with 4 "players" just like the real game so 4 people can use the program at once. This would be okay with the current game simulator too. Am I making sense?
The final version will have 4 robots...i just put up the code(only has 2 bots now) in hopes that someone would see what i'm doing wrong.
01-05-2003, 11:54 PM
umm ya, just do this
Turn DragMode automatic whatever in the properties window, right then on the place where it lands, use the drag drop event and get the object that was dropped with the parameter.
I would give you a more accurate description of how to do this but I was too lazy to open VB. This should work, if it doesn't then I'll tell you how to fix it, or send you a sample.
DragMode = Automatic
Object receiving event DragDrop, in that event do your stuff
Bleah, I dont use MOVE either
I jsut do object.left
because if you use X and Y, it does placements based on your desktop I think ya thats it
sry, just a cheap lazy message trying to fix some c++ bug
- Ryan Waliany
I'm not really following you. I'm trying to simply drag an objecct and make it stay where it was droped, I can manage to do it with one objeect, but not with multiple ones.
01-06-2003, 12:06 AM
What do you mean one, and not others? Do you have Aim, Icq, MSN, or Yahoo. I could probably explain it better on one of those.
Aim: Ryan Waliany, Icq: 11032544, MSN, email@example.com, yahoo Ryan_waliany
01-06-2003, 12:14 AM
Source code of VB proj which does it...
01-06-2003, 08:38 AM
From what you have said, it appears that your code may be moving both objects when you only click and drag one. The destination would be in the same place with one object completely covering the first.
thanx every1 who helped me, i finaly fixed the problem
vBulletin® v3.6.4, Copyright ©2000-2015, Jelsoft Enterprises Ltd.