Click here to Skip to main content
15,898,373 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: VB6 card game question Pin
ymilan15-May-09 11:27
ymilan15-May-09 11:27 
GeneralRe: VB6 card game question Pin
riced18-May-09 6:11
riced18-May-09 6:11 
GeneralRe: VB6 card game question Pin
ymilan18-May-09 9:22
ymilan18-May-09 9:22 
GeneralRe: VB6 card game question Pin
ymilan2-Jun-09 14:26
ymilan2-Jun-09 14:26 
GeneralRe: VB6 card game question Pin
riced3-Jun-09 4:42
riced3-Jun-09 4:42 
GeneralRe: VB6 card game question Pin
ymilan3-Jun-09 5:10
ymilan3-Jun-09 5:10 
GeneralRe: VB6 card game question Pin
ymilan3-Jun-09 6:28
ymilan3-Jun-09 6:28 
GeneralRe: VB6 card game question Pin
riced3-Jun-09 8:06
riced3-Jun-09 8:06 
Firstly, I don't think you should be messing with OLEDrag* at all, so would set OLEDragMode property to 0. OLE drag features are for dragging and dropping data rather than images. E.g. drag data between DataGrid controls.

Secondly, I don't think you should have loops in the Hearts_DragOver or Hearts_DragDrop events. You probably should not be changing the value of Index (as the loops are doing) and I doubt that you should be changing the Source.Picture.

Imagine the following. There is a form with two control arrays called theShapes and theBoxes. Both have say 5 items (so indexes go from 0 to 4) with theShapes on left of form; theBoxes on right.
The user clicks and drags e.g. theShapes(3) image over to the right.
Suppose it is dragged over theBoxes(1) image. Then the theBoxes_DragOver event is triggered with Index = 1 and State = 0. So in the code the only image that should change color is theBoxes(1). All the other theBoxes() images should remain as they were. So no loop required. Also, the Source is theShapes(3) and presumably you don't want its picture to change. So you never want to be doing something like Source.Picture = SomeOtherControl.Picture.
Suppose that the object is to place the correct shapes in the correct boxes. So at the start theBoxes() all have some blank image; theShapes() all have some appropriate image. E.g. theShapes(3) could be a triangle, theShapes(4) could be a circle, etc. If the user drags a shape and drops it into a box, the box should only accept it if it is the correct shape. So e.g. if theShape(3) (i.e. a triangle) is dragged and dropped into theBoxes(1), the drop should only succeed if theBoxes(1) accepts triangles. So how do we tell if this is the case? We cannot compare pictures because theBoxes() are all a blank image so will never be the same as a shape image.
One way of doing this is to set the Tag property for each of the controls and compare the Tags before allowing the drop to succeed or fail.
E.g. when setting up the control arrays you would have something like
theShapes(3).Tag = "Triangle"
theBoxes(0).Tag = "Square"
theBoxes(1).Tag = "Triangle"
theBoxes(2).Tag = "Circle"
In the theBoxes_DragDrop event you would then have something like
If theBoxes(Index).Tag = Source.Tag Then
   'Allow the drop
Else
   'Cancel the drop
End If

I think this is how to do it. But to do so requires that the DragMode for theShapes() to be set to 0 (i.e. vbManual) and that the Drag method is implemented. I might be wrong about this, it may be possible to cancel the drop when mode is set to vbAutomatic but I can't think how it would work.
The DragMode should be set when the controls are created, I can't think of a good reason to set the mode in the DragDrop event of another control.
Finally, the mode for theBoxes controls should be set to vbManual and no Drag method implemented. This stops the user from dragging theBoxes controls around.

Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis

GeneralRe: VB6 card game question Pin
ymilan3-Jun-09 9:02
ymilan3-Jun-09 9:02 
GeneralRe: VB6 card game question Pin
riced3-Jun-09 10:04
riced3-Jun-09 10:04 
GeneralRe: VB6 card game question Pin
ymilan3-Jun-09 11:54
ymilan3-Jun-09 11:54 
GeneralRe: VB6 card game question Pin
ymilan4-Jun-09 2:47
ymilan4-Jun-09 2:47 
GeneralRe: VB6 card game question Pin
ymilan2-Jun-09 14:29
ymilan2-Jun-09 14:29 
GeneralRe: VB6 card game question Pin
ymilan2-Jun-09 23:24
ymilan2-Jun-09 23:24 
QuestionAttached to Events Pin
Thayhor6-May-09 8:55
Thayhor6-May-09 8:55 
AnswerRe: Attached to Events Pin
Dave Kreskowiak6-May-09 9:05
mveDave Kreskowiak6-May-09 9:05 
GeneralRe: Attached to Events Pin
Thayhor6-May-09 11:13
Thayhor6-May-09 11:13 
GeneralRe: Attached to Events Pin
Dave Kreskowiak6-May-09 15:30
mveDave Kreskowiak6-May-09 15:30 
GeneralRe: Attached to Events Pin
Thayhor6-May-09 21:05
Thayhor6-May-09 21:05 
GeneralRe: Attached to Events Pin
Dave Kreskowiak7-May-09 1:49
mveDave Kreskowiak7-May-09 1:49 
Questioncheckedlistbox in vb.net Pin
Pankaj-codeproject6-May-09 8:46
Pankaj-codeproject6-May-09 8:46 
AnswerRe: checkedlistbox in vb.net Pin
Dave Kreskowiak6-May-09 9:15
mveDave Kreskowiak6-May-09 9:15 
GeneralRe: checkedlistbox in vb.net Pin
Pankaj-codeproject6-May-09 20:55
Pankaj-codeproject6-May-09 20:55 
QuestionPlaying Music in VB.Net application [modified] Pin
DarkSorrow386-May-09 8:12
DarkSorrow386-May-09 8:12 
AnswerRe: Playing Music in VB.Net application Pin
Dave Kreskowiak6-May-09 8:35
mveDave Kreskowiak6-May-09 8:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.