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 SRCCOPY = &HCC0020
Private Const COLORONCOLOR = 3
Private Sub Command1_Click()
Dim ret As Long
Picture2.Cls
ret = StretchBlt(Picture2.hdc, 0, 0, Picture2.Width, Picture2.Height,
Picture1.hdc, 0, 0, Picture1.Width, Picture1.Height, SRCCOPY)
End Sub
Private Sub Command2_Click()
Dim ret As Long
Picture2.Cls
ret = SetStretchBltMode(Picture2.hdc, COLORONCOLOR)
ret = StretchBlt(Picture2.hdc, 0, 0, Picture2.Width, Picture2.Height,
Picture1.hdc, 0, 0, Picture1.Width, Picture1.Height, SRCCOPY)
End Sub
Private Sub Form_Load()
Form1.ScaleMode = vbPixels
Command1.Caption = "Case1"
Command2.Caption = "Case2"
End Sub