Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 164
  • Last Modified:

Re-sizing bitmaps

I need to make a utility which allows the user to re-position and resize a picture box. Can this be done using drag-drop for re-positioning where the box stays where the 'shadow' is? I am using a control array, but the re-sizing part is difficult.
0
mi5
Asked:
mi5
  • 2
1 Solution
 
mdouganCommented:
What part in particular is difficult?  Plus, it's not quite clear what you mean by the box staying where the shadow is.  Yes, it can be done using drag-drop, it's a little tricky, but not too difficult.

MD
0
 
mi5Author Commented:
I had done this before by setting the picture box left to the 'X' mouse coordinate, and the top property to the 'Y' mouse coordinate. How can I re-size (make bigger of smaller) the box, using a suitable cursor and 'shadow'?
0
 
mdouganCommented:
For dragging a picture box around, here is some sample code that will make the operation a little smoother.  Please note, that the code for moving the picturebox is in the Form's DragDrop event, so, if the user drags the picturebox just a little ways, and drops it, then the picturebox itself may be the one getting the dragdrop event (so the picture box wont move).  You can try copying the code in the form's dragdrop event to the pictureboxes dragdrop event and this will help, but sometimes the coordinates get confused and the box jumps around.

Dim XPos As Single
Dim YPos As Single

Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
    Picture1.Move (X - XPos), (Y - YPos)
End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    XPos = X
    YPos = Y
    Picture1.Drag 1
End Sub

To get the sizing arrows to change, add the following code:

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (X < 10) Or ((X > (Picture1.Width - 10)) And (X < Picture1.Width)) Then
        Picture1.MousePointer = vbSizeWE
    ElseIf (Y < 10) Or ((Y > (Picture1.Height - 10)) And (Y < Picture1.Height)) Then
        Picture1.MousePointer = vbSizeNS
    Else
        Picture1.MousePointer = 0
    End If
End Sub

To get the sizing to happen correctly, you have to determine in the picture's mousedown event if you are on the border or in the middle of the control to decide if you should begin dragging the control, or if you should start sizing it.  I don't have the time at the moment to experiment, but why don't you play with this and see how far you get?  And, I'll get back to you later.

MD
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now