我在picture1控件中加载了一个图形,怎样实现 窗口缩放的时候,里面的图形也是等
比例的缩放,能给点代码吗

解决方案 »

  1.   

    由于Picture本身无拉伸Stretch功能,建议你用Image控件或是将Image控件贴于Picture中
    实现代码如下:
    Private Sub Form_Resize()
       Picture1.Height=Me.Height
       Picture1.Width=Me.Height
       Picture1.Top=0
       Picture1.Left=0
    End Sub
    是实现图片贴于整个窗口
      

  2.   

    注意:将Image的Stretch属性设为True即允许拉伸
      

  3.   

    干脆写代码在PictureBox改变大小时重画,可用API函数Stretch ,PictureBox的AuotDraw属性设为True,画完后Refresh一下即可:)
      

  4.   

    使用PICTUREBOX的PAINTPICTURE方法,很容易做到的。
      

  5.   

    Option Explicit
    Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
    Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
    Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    Private 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 BitBlt Lib "gdi32" (ByVal hDestDC 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 dwRop As Long) As Long
    Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
    Private Const SRCCOPY = &HCC0020Dim memdc As Long
    Dim membmp As Long
    Dim oldbmp As Long
    Dim xx As Long
    Dim yy As Long
    Private Sub Form_Load()
        Load Me
        Me.Hide
        memdc = CreateCompatibleDC(Me.hdc)
        xx = Me.ScaleWidth / 15
        yy = Me.ScaleHeight / 15
        membmp = CreateCompatibleBitmap(Me.hdc, xx, yy)
        oldbmp = SelectObject(memdc, membmp)
        Me.AutoRedraw = True
        Me.Picture = LoadPicture("d:\desktop\install0.bmp")
        BitBlt memdc, 0, 0, xx, yy, Me.hdc, 0, 0, SRCCOPY
        Set Me.Picture = Nothing
        Me.Cls
        StretchBlt Me.hdc, 0, 0, Me.ScaleWidth / 15, Me.ScaleHeight / 15, memdc, 0, 0, xx, yy, SRCCOPY
        Me.Show
    End SubPrivate Sub Form_Resize()
        Me.Cls
        StretchBlt Me.hdc, 0, 0, Me.ScaleWidth / 15, Me.ScaleHeight / 15, memdc, 0, 0, xx, yy, SRCCOPY
    End SubPrivate Sub Form_Unload(Cancel As Integer)
        SelectObject memdc, oldbmp
        DeleteObject membmp
        DeleteDC memdc
    End Sub