Solved

Re-sizing bitmaps

Posted on 1999-01-21
3
158 Views
Last Modified: 2010-05-03
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
Comment
Question by:mi5
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Expert Comment

by:mdougan
ID: 1469816
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
 

Author Comment

by:mi5
ID: 1469817
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
 
LVL 18

Accepted Solution

by:
mdougan earned 40 total points
ID: 1469818
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question