Solved

Re-sizing bitmaps

Posted on 1999-01-21
3
155 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
  • 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

815 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now