哪位VB高手给个雪花屏保啊?
- 提问者网友:孤山下
- 2021-04-29 12:56
- 五星知识达人网友:第幾種人
- 2021-04-29 13:32
我找了个实例,给你参考吧,效果也可以,全部代码复制到TXT里,保存为.frm文件,直接打开运行即可,点击图片看到效果,双击退出
Option Explicit
Private Type h
X As Integer
Y As Integer
c As Long
End Type
Dim xh(1000) As h
Dim picw As Long
Dim pich As Long
Dim bgcolor
Private Sub Form_Load()
Form1.Caption = "2005年的那场雪"
Picture1.Picture = LoadPicture(App.Path & "\snow.bmp")
With Picture1
.Top = 0
.Left = (Form1.ScaleWidth = Picture1.ScaleWidth) / 2 - 1.5
.AutoRedraw = True
.AutoSize = True
.ScaleMode = 3
End With
picw = Picture1.ScaleWidth
pich = Picture1.ScaleHeight
bgcolor = Picture1.Point(1, 1)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Picture1.Left = (Form1.ScaleWidth = Picture1.ScaleWidth) / 2
picw = Picture1.ScaleWidth
pich = Picture1.ScaleHeight
End Sub
Private Sub Picture1_Click()
Dim i
Dim speedx, speedy
Picture1.Cls
For i = 1 To 1000
xh(i).Y = Int(Rnd(1) * (-pich))
xh(i).X = Int(Rnd(1) * picw)
Next i
Do
DoEvents
For i = 1 To 1000
If xh(i).c = bgcolor Then
Picture1.PSet (xh(i).X, xh(i).Y), xh(i).c
Else
xh(i).Y = Int(Rnd(1) * (pich))
xh(i).X = Int(Rnd(1) * picw)
End If
If xh(i).Y > pich Then
xh(i).Y = Int(Rnd(1) * (-pich))
xh(i).X = Int(Rnd(1) * picw)
End If
speedx = 1 - Rnd(1) * 2
speedy = Rnd(1) * 2
xh(i).Y = xh(i).Y + speedy
xh(i).X = xh(i).X + speedx
xh(i).c = Picture1.Point(xh(i).X, xh(i).Y)
Picture1.PSet (xh(i).X, xh(i).Y), &H80000005
Next i
Loop
End Sub
Private Sub Picture1_DblClick()
End
End Sub