Results 1 to 7 of 7

Thread: picture box dragging.. better way to do it?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    20

    picture box dragging.. better way to do it?

    hi i have been using the dragover tool to transport images from picturebox to picturebox, but if i have selected a box and move my cursor over another picturebox the variable which is saved, which function should i use ? or can i stop it changing by adding another varaible!?

    At the moment i just use something such as this

    Private Sub Pic_temp7_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
    Set Selected = Pic_temp7 'creates the temporary picture
    End Sub


    but as i said before if i move my cursor over another pic_temp it will replace the image which has been placed there...

  2. #2
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Re: picture box dragging.. better way to do it?

    The DragOver and DragDrop events are for backward compatibility.
    You should use the OLEDrag... events instead.

    Here is a simple example to drag an image from one picturebox to another.

    VB Code:
    1. Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2.     Picture1.OLEDrag
    3. End Sub
    4.  
    5. Private Sub Picture1_OLEStartDrag(Data As DataObject, AllowedEffects As Long)
    6.     Data.SetData Picture1.Picture, vbCFBitmap
    7.     AllowedEffects = vbDropEffectCopy
    8. End Sub
    9.  
    10. Private Sub Picture2_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
    11.     Set Picture2.Picture = Data.GetData(vbCFBitmap)
    12. End Sub
    Frans

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    20

    Re: picture box dragging.. better way to do it?

    when i implement this it says, object required... thanks for the help but whats wrong now?

    edit: i DID edit the code so it should run correctly, as i do have all the objects named correctly....
    Last edited by deathmage; Apr 21st, 2006 at 04:30 AM.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    20

    Re: picture box dragging.. better way to do it?

    sorry, i just realised i didnt do an oledragdrop command just the drag drop one...

    there is still an error though, it dosent display the picture which i drag into the box, the image dosent change

  5. #5
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Re: picture box dragging.. better way to do it?

    The picturebox that you want to drop into, must have the property OLEDropMode set to 1-manual.
    The picturebox you want to drag from, must have the OLEDragMode property set to 0-manual, but that is the default.

    You could set both to automatic, and you would require much less code (or no code at all), but you would have much less control over it.
    Frans

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    20

    Re: picture box dragging.. better way to do it?

    um im not sorry to sound rude, but i got it to work and the ole gui, the way in which it actually represents the drag isnt the way which i want it to show, i want it to have the box movement shown up as if it was just a normal drag, is there a way to mask the way which the gui works? or can i do it another way>?

  7. #7
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Re: picture box dragging.. better way to do it?

    I think you noticed the are more OLE drag/drop events then I used.
    I don't know all the details, but I think this website can give you more information.
    Frans

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width