computer 版 (精华区)

发信人: windoe (为中国电信做贡献), 信区: program
标  题: VB:Windows 95的墙纸可以平铺一副图片,如何在VB中实
发信站: 听涛站 (Fri Mar 10 19:09:16 2000), 转信

VB里面有个方法(Method)叫PaintPicture,可以用来拷贝图片到新的位置。我们就
利用这个方法把一副小小的图片(可以是BMP,WMF,GIF,JPG)填满整个窗体,实现平铺
图片的功能。
具体步骤如下:
1) 在VB中新建一个标准EXE工程;
2) 定义Image1,设置Image1的Picture属性,读取图片文件。
3) 在Form_Paint()事件中编写程序如下:
Private Sub Form_Paint()
Dim X As Integer, Y As Integer
Dim ImgWidth As Integer
Dim ImgHeight As Integer
Dim FrmWidth As Integer
Dim FrmHeight As Integer
'初始化
ImgWidth = Image1.Width
ImgHeight = Image1.Height
FrmWidth = Form1.Width
FrmHeight = Form1.Height
'开始平铺
'开始平铺
For X = 0 To FrmWidth Step ImgWidth
For Y = 0 To FrmHeight Step ImgHeight
PaintPicture Image1, X, Y
Next Y
Next X
End Sub


--By Kammi's SuperPost General Version
--

夜中不能寐,起坐弹鸣琴。
    薄帷鉴明月,清风吹我襟。
孤鸿号外野,翔鸟鸣北林。
    徘徊将何见,忧思独伤心。


[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:0.868毫秒