Results 1 to 3 of 3

Thread: how to zoom ?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    how to zoom ?

    I use picturebox. How I can zoom in and zoom out when I draw rectangle within the picturebox?

  2. #2
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: how to zoom ?

    Do a search for the StretchBlt API. Lots of examples here such as http://www.vbforums.com/showthread.p...ght=StretchBlt

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: how to zoom ?

    I have problem here. Code below work for image or picture in the picturebox. But I not have picture in the picturebox.. It just line draw in the picturebox.. So I cannot see the line.

    Code:
    Private Sub picView_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        mbDragging = True
        picView.DrawMode = vbInvert
        With mRect
            .Left = X
            .Top = Y
            .Right = X
            .Bottom = Y
        End With
    End Sub
    
    Private Sub picView_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim sHexDec$, sTip$
    
    On Error Resume Next
    
        If Not mbDragging Then
            sHexDec = Hex(picView.Point(X, Y))
            sTip = "R: " & CLng("&H" + Mid(sHexDec, 1, 2)) & Space(5 - Len(CStr(CLng("&H" + Mid(sHexDec, 1, 2))))) & _
                   "G: " & CLng("&H" + Mid(sHexDec, 3, 2)) & Space(5 - Len(CStr(CLng("&H" + Mid(sHexDec, 3, 2))))) & _
                   "B: " & CLng("&H" + Mid(sHexDec, 5, 2))
            picView.ToolTipText = sTip
            Exit Sub
        End If
        With mRect
            ' erase box
            picView.Line (.Left, .Top)-(.Right, .Bottom), , B
            .Right = X
            .Bottom = Y
            ' draw box
            picView.Line (.Left, .Top)-(X, Y), , B
        End With
    
    End Sub
    
    Private Sub picView_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    '===========================================================================================
    Dim dblZoom As Double
    
    On Error Resume Next
    
        mbDragging = False
        ' erase box by redrawing
        picView.Line (mRect.Left, mRect.Top)-(mRect.Right, mRect.Bottom), , B
        picView.DrawMode = vbCopyPen
        
        'show selected in the Picture2
        If IsNumeric(Trim(txtZoom.Text)) Or Trim(txtZoom.Text) = "" Then
            If Trim(txtZoom.Text) = "" Then dblZoom = 1
            dblZoom = CDbl(Trim(txtZoom.Text))
            Picture2.Cls
            Picture2.PaintPicture picView.Picture, _
                                  0, _
                                  0, _
                                  Abs(mRect.Right - mRect.Left) * dblZoom, _
                                  Abs(mRect.Bottom - mRect.Top) * dblZoom, _
                                  mRect.Left, _
                                  mRect.Top, _
                                  Abs(mRect.Right - mRect.Left), _
                                  Abs(mRect.Bottom - mRect.Top)
        Else
            MsgBox "Invalid zoom value - it must be numeric!"
            txtZoom.SelStart = 0
            txtZoom.SelLength = Len(txtZoom.Text)
            txtZoom.SetFocus
        End If
    
    End Sub
    Attached Images Attached Images  

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