五笔打字通主页
有时我们需要将一个小的图片平铺到整个窗体。这个功能可以用PaintPicture方法来实现。
先在窗体上画一个picturebox控件,控件的picture属性大家自行设置一个小图片,具体代码是:
Private Sub Form_Paint()
Dim PicW_Sng As Single
Dim PicH_Sng As Single
Dim x As Single
Dim y As Single
' 获取图像的尺寸
PicW_Sng = Picture1.ScaleWidth
PicH_Sng = Picture1.ScaleHeight
' 绘制平铺图像
y = 0
Do While y < ScaleHeight
x = 0
Do While x < ScaleWidth
PaintPicture Picture1.Picture, x, y
x = x + PicW_Sng
Loop
y = y + PicH_Sng
Loop
End Sub
运行后,就会看到picturebox控件里的图片平铺到整个窗体了。
来源:济亨网
本文链接:https://wb98.com/post/48.html