7,762
社区成员
发帖
与我相关
我的任务
分享
'窗体上放一个命令按钮Command1,2个图片框控件Picture1,picture2。Picture1比picture2大,在picture2中装入一张小图片。
'程序启动后,这张小图片就会铺满整个picture1
Option Explicit
Private Declare Function BitBlt Lib "gdi32.dll" (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 Const SRCCOPY As Long = &HCC0020
Private Sub Command1_Click()
Dim W1 As Long, W2 As Long, H1 As Long, H2 As Long
Dim hDC1 As Long, hDC2 As Long
Dim i As Long, j As Long
W1 = Picture1.ScaleWidth
W2 = Picture2.ScaleWidth
H1 = Picture1.ScaleHeight
H2 = Picture2.ScaleHeight
hDC1 = Picture1.hDC
hDC2 = Picture2.hDC
Debug.Print W1 \ W2, H1 \ H2
For i = 0 To W1 \ W2
For j = 0 To H1 \ H2
BitBlt hDC1, i * W2, j * H2, W2, H2, hDC2, 0, 0, SRCCOPY
Next
Next
End Sub
Private Sub Form_Load()
Me.ScaleMode = 3
Picture1.ScaleMode = 3
Picture2.ScaleMode = 3
Picture1.AutoSize = False
Picture2.AutoSize = True
Picture1.AutoRedraw = False
'事先在picture2中加载一张小图片,我这里加载的是80X78的.程序启动后,这张小图片就会铺满整个picture1。
Picture2.Picture = LoadPicture("F:\资料\My Pictures\28_meigui_18.jpg")
End Sub