Results 1 to 3 of 3

Thread: Zoom

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Vaxjo, Sweden
    Posts
    85
    First, I'd suggest the image control instead of the picture box.
    1) Put a frame with no border on your form.
    2) Place an image inside the frame.
    3) Set the imagecontrols "stretch" property to TRUE.
    3) When the user clicks the button, enlarage the imagecontrol, and set it's "top" and "left" properties so it shows the correct part of the picture.

    Should work...

    //Anders

  2. #2
    Guest

    Lightbulb Use PaintPicture

    If you want to keep the PictureBox, use the PaintPicture method for the Zooming. For this, you need to create 2 PictureBoxes. Load your Picture into Picture2.

    Code:
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    
    
        'Make the Picture twice as large
        If KeyCode = vbKeyAdd Then
            With Picture1
                .Cls
                .Width = .Width * 2
                .Height = .Height * 2
                .PaintPicture Picture2.Picture, 0, 0, .ScaleWidth, .ScaleHeight
            End With
        End If
    
    
        'Make the Picture twice as small
        If KeyCode = vbKeySubtract Then
            With Picture1
                .Cls
                .Width = .Width / 2
                .Height = .Height / 2
                .PaintPicture Picture2.Picture, 0, 0, .ScaleWidth, .ScaleHeight
            End With
        End If
    
        'Center the PictureBox
        Picture1.Move (Me.ScaleWidth / 2) - (Picture1.Width / 2), (Me.ScaleHeight / 2) - (Picture1.Width / 2)
        
    End Sub
    
    Private Sub Form_Load()
    
        'Make Picture2 invisible
        Picture2.Visible = False
        'Make the Form recieve Key events before Controls
        Me.KeyPreview = True
        'ReDraw the Picture so it doesn't get cut off
        Picture1.AutoRedraw = True
        'Draw the Picture on to Picture1
        Picture1.PaintPicture Picture2.Picture, 0, 0
        
    End Sub
    When you press Add or Subtract, it will Zoom in and Zoom out.

  3. #3
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    k, thanks guys, i think i will keep the picture box and use Megatron's way, but thanks to Anders Englund too. !!! :P

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width