Solved

Re-sizing bitmaps

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…

759 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

19 Experts available now in Live!

Get 1:1 Help Now