请教Form中的picture属性添加图片的问题
问一下大家,FORM中的picture属性添加了图片,图片什么样自动调整大小和窗体的大小一致
可用分不多大家见谅
谢谢
Option Explicit 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 CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function DeleteDC 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 IsIconic Lib "user32" (ByVal hwnd As Long) As Long Private mPic As StdPicture, px&, py& Private mMemDC As Long Private Sub Form_Load() Me.ScaleMode = vbPixels Set mPic = LoadPicture("D:\My Documents\My Pictures\头像.gif") px& = Me.ScaleX(mPic.Width, ScaleModeConstants.vbHimetric, vbPixels) py& = Me.ScaleY(mPic.Height, ScaleModeConstants.vbHimetric, vbPixels) mMemDC = CreateCompatibleDC(Me.hdc) Debug.Print mMemDC, px, py End Sub Private Sub Form_Paint() Dim hBmpTmp& hBmpTmp& = SelectObject(mMemDC, mPic.Handle) StretchBlt Me.hdc, 0, 0, Me.ScaleWidth, Me.ScaleHeight, _ mMemDC, 0, 0, px&, py&, vbSrcCopy Call SelectObject(mMemDC, hBmpTmp&) End Sub Private Sub Form_Resize() If IsIconic(Me.hwnd) Then Else Form_Paint End If End Sub Private Sub Form_Unload(Cancel As Integer) DeleteDC mMemDC End Sub