Solved

Re-sizing bitmaps

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
message box in access 4 51
Excel Automation VBA 19 91
VB6 - Cannot type when doing an extract from MSHFlexgrid to Excel 6 20
checkbox to hide entire section 10 43
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

820 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