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 SetStretchBltMode Lib "gdi32" (ByVal hdc As Long, ByVal nStretchMode As Long) As Long Private Const HALFTONE = 4 Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source Dim Rtn As Long Dim hDC1 As Long, hDC2 As Long Private Sub Form_Load() Me.AutoRedraw = True Me.ScaleMode = 3 Picture1.ScaleMode = 3 Picture1.AutoRedraw = True Picture1.AutoSize = True Picture1.Visible = False Picture1.Picture = LoadPicture("e:\LENOVO1.BMP") hDC1 = Picture1.hdc hDC2 = Me.hdc Call SetStretchBltMode(hDC2, HALFTONE) Rtn = StretchBlt(hDC2, 0, 0, Me.ScaleWidth, Me.ScaleHeight, hDC1, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, SRCCOPY) End SubPrivate Sub Form_Resize() Rtn = StretchBlt(hDC2, 0, 0, Me.ScaleWidth, Me.ScaleHeight, hDC1, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, SRCCOPY) Me.Refresh End Sub
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 SetStretchBltMode Lib "gdi32" (ByVal hdc As Long, ByVal nStretchMode As Long) As Long
Private Const HALFTONE = 4
Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Dim Rtn As Long
Dim hDC1 As Long, hDC2 As Long
Private Sub Form_Load()
Me.AutoRedraw = True
Me.ScaleMode = 3
Picture1.ScaleMode = 3
Picture1.AutoRedraw = True
Picture1.AutoSize = True
Picture1.Visible = False
Picture1.Picture = LoadPicture("e:\LENOVO1.BMP")
hDC1 = Picture1.hdc
hDC2 = Me.hdc
Call SetStretchBltMode(hDC2, HALFTONE)
Rtn = StretchBlt(hDC2, 0, 0, Me.ScaleWidth, Me.ScaleHeight, hDC1, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, SRCCOPY)
End SubPrivate Sub Form_Resize()
Rtn = StretchBlt(hDC2, 0, 0, Me.ScaleWidth, Me.ScaleHeight, hDC1, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, SRCCOPY)
Me.Refresh
End Sub
commandbutton也是可以的,不过要将style设为1.