可以先用一个隐藏的picturebox加载图片,然后用bitblt函数画到你要显示的picbox上就可以了

解决方案 »

  1.   

    如果允许的话你可以用Image控件,将Stretch属性设为True即可。
      

  2.   

    Private Sub Command1_Click()
      Dim Pic As StdPicture
      Set Pic = LoadPicture(FileName)
      Picture1.AutoRedraw = True
      Picture1.PaintPicture Pic, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight
    End Sub
      

  3.   

    上面的大哥以经说了不是,用AutoRedraw属性不就完了吗!
      

  4.   

    Private Sub Command1_Click()
        Image1.Stretch=True
        Image1.Width=Picture1.Width
        Image1.Height=Picture1.Height
    End Sub
      

  5.   

    这个image1放在picture里面
    Image1.Left=0
    Image1.Top=0
      

  6.   

    一个带滚动条的,有picturebox.image,要image的 stretch设为true.我正在写一个相关的程序,有事可以发信给我[email protected]
    Public c1, c2, c3, c4 As Integer
    Public tf, d1, d2, d3, d4, blf As Integer
    Public yk, yg As LongOption ExplicitPrivate Type POINTAPI
    X As Long
    Y As Long
    End TypeConst SRCCOPY = &HCC0020
    Const SWP_NOMOVE = &H2
    Const SWP_NOSIZE = &H1
    Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
    Const HWND_TOPMOST = -1Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As LongDim pos As POINTAPI
    Dim xx As Integer
    Dim yy As IntegerPrivate Sub Form_Load()
    c1 = Form1.Width
    c2 = Form1.Height
    blf = 100yk = Image1.Width
    yg = Image1.Height
    If Image1.Width > Form1.Width And Image1.Height < Form1.Height Then
     VScroll1.Visible = False
     HScroll1.Visible = True
     Else
     If Image1.Width > Form1.Width And Image1.Height > Form1.Height Then
      VScroll1.Visible = True
      HScroll1.Visible = True
     Else
     If Image1.Width < Form1.Width And Image1.Height < Form1.Height Then
     VScroll1.Visible = False
     HScroll1.Visible = False
     Else
     If Image1.Width < Form1.Width And Image1.Height > Form1.Height Then
     VScroll1.Visible = True
     HScroll1.Visible = False
     
    End If
    End If
    End If
     End If
     SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS
    xx = 200
    yy = xx
    MousePointer = 0
    End SubPrivate Sub Form_Resize()
    If Width > 1500 And Height > 1170 Then
    c3 = Form1.Width - c1
    c4 = Form1.Height - c2
    Picture1.Move Picture1.Left, Picture1.Top, Picture1.Width + c3, Picture1.Height + c4
    c1 = Form1.Width
    c2 = Form1.Height
    Call p
    End If
    End SubPrivate Sub HScroll1_Change()
    Image1.Left = -HScroll1.Value
    End SubPrivate Sub p()
    Image1.Move 0, 0
    HScroll1.Top = Picture1.Height + Picture1.Top
    HScroll1.Left = Picture1.Left
    HScroll1.Width = Picture1.Width
    VScroll1.Top = Picture1.Top
    VScroll1.Left = Picture1.Width + Picture1.Left
    VScroll1.Height = Picture1.Height
    HScroll1.Max = (Image1.Width - Picture1.Width)
    VScroll1.Max = (Image1.Height - Picture1.Height)
    VScroll1.Visible = (Picture1.Height < Image1.Height)
    HScroll1.Visible = (Picture1.Width < Image1.Width)End SubPrivate Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    d1 = X
    d2 = Y
    Image1.Drag 1
    Set Image1.DragIcon = LoadPicture("d:\bmp\viewer.ico")
    MousePointer = 1
    start
    'Image1.Refresh
    'Form1.Refresh
    End SubPrivate Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Y > Image1.Top And Y < Image1.Top + Image1.Height Then
    VScroll1.Value = (Y - Image1.Top) / (Image1.Height) * 300
    End If
    If X > Image1.Left And X < Image1.Left + Image1.Width Then
    HScroll1.Value = (X - Image1.Left) / (Image1.Width) * 300
    End If
    End SubPrivate Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Image1.Refresh
    MousePointer = 0
    Form1.Refresh
    End SubPrivate Sub VScroll1_Change()
    Image1.Top = -VScroll1.ValueEnd SubPrivate Sub fs()
    Dim bl As Variant
    bl = bl1 / 100
    Form1.MousePointer = vbHourglass
    Picture2.Width = yk * bl
    Picture2.Height = yg * bl
    Picture2.Refresh
    Picture2.PaintPicture Picture2.Picture, 0, 0, yk * bl, yg * bl, 0, 0, yk, yg
    Call p
    If VScroll1.Visible Then
    VScroll1.Value = IIf(VScroll1.Value * bl > VScroll1.Max, VScroll1.Max, VScroll1.Value * bl)
    End If
    If HScroll1.Visible Then
    HScroll1.Value = IIf(HScroll1.Value * bl > HScroll1.Max, HScroll1.Max, HScroll1.Value * bl)
    End If
    Form1.MousePointer = vbDefaultEnd Sub
    Public Sub start()
    Dim sx As Integer
    Dim sy As Integer
    GetCursorPos pos
    sx = IIf(pos.X < 50 Or pos.X > 590, IIf(pos.X < 50, 0, 540), pos.X - 10)
    sy = IIf(pos.Y < 50 Or pos.Y > 590, IIf(pos.Y < 50, 0, 380), pos.Y - 10)
    Caption = sx & "," & sy
    If pos.X < 400 And pos.Y < 400 Then
    StretchBlt hdc, pos.X, pos.Y, xx, yy, GetDC(0), sx, sy, 40, 40, SRCCOPY
    Else
    If pos.X < 400 And pos.Y > 400 Then
    StretchBlt hdc, pos.X, pos.Y - yy, xx, yy, GetDC(0), sx, sy, 40, 40, SRCCOPY
    Else
    StretchBlt hdc, pos.X - xx, pos.Y - yy, xx, yy, GetDC(0), sx, sy, 40, 40, SRCCOPY
    End If
    End If
    End Sub