Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Visual Basic - Drag and Drop (http://www.chiefdelphi.com/forums/showthread.php?t=15927)

Gope 05-01-2003 23:04

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!!!!

iscrc2 05-01-2003 23:56

on a form not forum right? Are you setting both objects to drag mode=automatic?

Rickertsen2 06-01-2003 00:14

i am considering making a web based scoring simulator for everyone. Tell me how ur sim goes. Can u post it when ur finished¿

Gope 06-01-2003 00:18

This is my program, except for the positioning junk, it dosent work in vbManual or vbAutomatic.




Private xoffset As Integer
Private yoffset As Integer
Option Explicit

Private Sub ba_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
xoffset = X
yoffset = Y
ba.Drag vbBeginDrag

End Sub

Private Sub bb_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
xoffset = X
yoffset = Y
bb.Drag vbBeginDrag

End Sub

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)

End Sub






ya, if i finish this, i'll pass it out to whoever wants it.

sanddrag 06-01-2003 00:52

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?

Gope 06-01-2003 00:53

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.

rwaliany 06-01-2003 00:54

Heres how to fix
 
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
k

Bleah, I dont use MOVE either
I jsut do object.left
object.top =
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

Gope 06-01-2003 00:59

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.

rwaliany 06-01-2003 01:06

Hrmmm
 
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, ryan@scv.net, yahoo Ryan_waliany

rwaliany 06-01-2003 01:14

Drag Drop
 
1 Attachment(s)
Source code of VB proj which does it...

josh_johnson 06-01-2003 09:38

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.

Gope 06-01-2003 09:42

thanx every1 who helped me, i finaly fixed the problem


All times are GMT -5. The time now is 00:12.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi