resizing and zorder(vb6)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akynaya
    New Member
    • Jul 2007
    • 27

    #1

    resizing and zorder(vb6)

    i have a problem regarding resizing of images that is to be displayed using the picture box.

    i also have a problem about the dragging and dropping method because the images tend to drag to a different location.

    this is my drag n drop code:

    [CODE=vb]Private Sub Picture28_DragD rop(Source As Control, X As Single, Y As Single)
    If X > X1 Then Source.Left = Source.Left + (X - X1) Else Source.Left = Source.Left - (X1 - X)
    If Y > Y1 Then Source.Top = Source.Top + (Y - Y1) Else Source.Top = Source.Top - (Y1 - Y)
    End Sub
    Private Sub Picture28_Mouse Down(Button As Integer, Shift As Integer, X As Single, Y As Single)
    X1 = X
    Y1 = Y
    Picture28.Drag
    Picture28.ZOrde r
    End Sub[/CODE]

    thank you for your help
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by akynaya
    i have a problem regarding resizing of images that is to be displayed using the picture box.
    You didn't say what the problem is. I can give you two things to think about though, in relation to image resizing.
    1. Use Image control rather than PictureBox. Check out the Stretch property.
    2. PaintPicture method.


    Originally posted by akynaya
    i also have a problem about the dragging and dropping method because the images tend to drag to a different location.
    I think I know this one. When you drop, it just drops the image with the top-left corner at the mouse position, correct?

    If you are only dragging within your application (not dropping images onto your application from somewhere else) then that's easy to get around. When you pick up (start drag), record the position of the mousepointer within the control. When you drop, offset the location by that amount (negative).

    What does Zorder have to do with the question?

    Comment

    • akynaya
      New Member
      • Jul 2007
      • 27

      #3
      im really sorry if my questions are to broad and not that clear... i havent had a decent sleep these days...

      anyway, im going to really clear this one...

      im using a picture box because most of my images are in bitmaps. although an image box is really handy and more versatile in terms of space consumption in the memory...

      anyways, the problem in resizing is that my teacher wants the images that i've loaded be resizable like those images in word or in visio, edraw...

      the problem with z order is that i've use it so as to prioritize the image that was being clicked by the user but unfortunately the drag n drop method is quite not in order.

      i would highly appreciate your help..... THANK YOU

      Comment

      • akynaya
        New Member
        • Jul 2007
        • 27

        #4
        i forgot to tell you about the drag n drop method that i've used, well, i need it so as to let the user drag or drop the object anywhere within the picturebox which is my set work area.

        the drag and drops works but if you'd click another image for the same purpose of dragging n droping, that's when the problem arises...

        the problem is that both of the pictures/images doesn't drag n drop to where the other image is and i am supposed to enable the images to drag n drop regardless whether another picture is in place.

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          So if I'm reading this correctly, the basic problem is that when you drop a picture on top of another one, it is detected by that picture instead of the form.

          If that is so, I don't know whether there's any way to avoid it (haven't had a lot of experience with D&D) but it might be possible to work around it by having the pictures detect another one being dropped on them, and pass it along to the form.

          I suspect your best bet might be to set up a generic "DropImageAtLoc ation" sub, which accepts all the information necessary to drop the currently dragged image at the specified location on the form. If an image detects the drop, it can adjust the location based on where it is, and pass that along to the routine.

          For example, say an image is sitting at location (5,5). If another one is dropped on it at location (15,40) it would adjust that to (20,45) and then tell the routine to drop it there.

          Comment

          Working...