VB6 Drag and Drop from one picturebox to another picturebox - basic.visual

This is a discussion on VB6 Drag and Drop from one picturebox to another picturebox - basic.visual ; Hi, I am using Visual Basic 6. I am having some trouble with dragging and dropping an image from one picture box to another picturebox. The destination picturebox's picture should be replaced entirely from the source picturebox's picture. I have ...

+ Reply to Thread
Results 1 to 3 of 3

VB6 Drag and Drop from one picturebox to another picturebox

  1. Default VB6 Drag and Drop from one picturebox to another picturebox

    Hi,

    I am using Visual Basic 6.

    I am having some trouble with dragging and dropping an image from one
    picture box to another picturebox. The destination picturebox's
    picture should be replaced entirely from the source picturebox's
    picture.

    I have defined 2 picturebox'es:
    picture1
    autoresize False
    autoredraw False
    dragmode Automatic
    drawmode Copy Pen
    picture2
    autoresize False
    autoredraw False
    dragmode Manual
    drawmode Copy Pen

    This is the code I have used:
    Private sub picture2_dragdrop(source as control, x as single, y as
    single)
    me.picture=source.picture
    source.picture=loadpicture("")
    end sub

    The image does get copied BUT appears behind the window of picture2
    and only a corner showing. I want the image from picture1 to be
    entirely inside the "frame" of picture2.

    The image ideally should get resized.

    How do I fix this?

    Thanks for any help.

    Ps. I have tried using paintpicture method as well and it does the
    same thing.
    I have also set autoresize, autoredraw on picture2 to true and it does
    the same thing.


  2. Default Re: VB6 Drag and Drop from one picturebox to another picturebox


    <pwu@qantas.com.au> wrote in message
    news:1171585646.024956.161360@l53g2000cwa.googlegroups.com...
    > Hi,
    >
    > This is the code I have used:
    > Private sub picture2_dragdrop(source as control, x as single, y as
    > single)
    > me.picture=source.picture
    > source.picture=loadpicture("")
    > end sub
    >
    > The image does get copied BUT appears behind the window of picture2
    > and only a corner showing. I want the image from picture1 to be
    > entirely inside the "frame" of picture2.
    >


    me.picture is referring to the picture property of the form, not of picture2.
    I think you mean
    picture2.picture = source.picture



  3. Default Re: VB6 Drag and Drop from one picturebox to another picturebox

    <pwu@qantas.com.au> wrote in message
    news:1171585646.024956.161360@l53g2000cwa.googlegroups.com...

    > The image does get copied BUT appears behind the
    > window of picture2 and only a corner showing. I want
    > the image from picture1 to be entirely inside the "frame"
    > of picture2. The image ideally should get resized.


    As Steve has already said, you need to use Picture2 as the destination
    instead of Me (which effectively refers to the Form). Also, if you want the
    picture to be resized then you'll need to paint it instead of assigning the
    picture property. Try this:

    Private Sub Picture2_DragDrop(Source As Control, _
    X As Single, Y As Single)
    Picture2.PaintPicture Source.Picture, 0, 0, _
    Picture2.ScaleWidth, Picture2.ScaleHeight
    Source.Picture = LoadPicture("")
    End Sub

    You haven't said whether or not you want the result to be persistent (which
    it will not be with the above code) but if you do then you should set
    picture2's Autoredraw property to True. The resultant stretched bitmap will
    then be persistent on the display and can be referenced in the Image
    property of Picture2 picture box, although you can transfer it to the
    Picture property if you wish. Note that the above simple stretching code
    takes no account of the aspect ratio of the original picture.

    Mike




+ Reply to Thread

Similar Threads

  1. .NET picturebox example
    By Application Development in forum labview
    Replies: 2
    Last Post: 10-31-2007, 05:15 AM
  2. how to drag and drop an array of picturebox
    By Application Development in forum CSharp
    Replies: 0
    Last Post: 10-19-2007, 02:13 PM
  3. how to drag and drop an array of picturebox
    By Application Development in forum CSharp
    Replies: 0
    Last Post: 10-18-2007, 06:41 AM
  4. Resetting picturebox.
    By Application Development in forum basic.visual
    Replies: 0
    Last Post: 06-19-2005, 10:07 AM
  5. Save Picturebox
    By Application Development in forum basic.visual
    Replies: 8
    Last Post: 06-22-2004, 07:31 PM