案頭下雪

來源:互聯網
上載者:User

Private Declare Function BitBlt Lib "gdi32" _
        (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 Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long

Const SRCCOPY = &HCC0020

Option Explicit
Private Sub CopyScreen()
With Me
    .AutoRedraw = True
    .Width = Screen.Width
    .Height = Screen.Height
       
    .WindowState = 2
    .BorderStyle = 0
End With

BitBlt Me.hDC, 0, 0, Screen.Width / 15, Screen.Height / 15, GetDC(0), 0, 0, SRCCOPY
End Sub
Private Sub fSnow()
Dim Snow(1000, 2), Amounty As Integer
Dim j, Ls, i As Integer
Dim OldX, OldY, Coloury As Long
Form1.Show
DoEvents
Randomize
Amounty = 325
For j = 1 To Amounty
Snow(j, 0) = Int(Rnd * Form1.Width)
Snow(j, 1) = Int(Rnd * Form1.Height)
Snow(j, 2) = 10 + (Rnd * 20)
Next j
Do While Not (DoEvents = 0)
For Ls = 1 To 10
For i = 1 To Amounty
OldX = Snow(i, 0): OldY = Snow(i, 1)
Snow(i, 1) = Snow(i, 1) + Snow(i, 2)
If Snow(i, 1) > Form1.Height Then
Snow(i, 1) = 0: Snow(i, 2) = 5 + (Rnd * 30)
Snow(i, 0) = Int(Rnd * Form1.Width)
OldX = 0: OldY = 0
End If
Coloury = 8 * (Snow(i, 2) - 10): Coloury = 60 + Coloury
PSet (OldX, OldY), vbWhite
PSet (Snow(i, 0), Snow(i, 1)), RGB(Coloury, Coloury, Coloury)
Next i
Next Ls
Loop
End Sub
Private Sub Form_Load()
'拷屏
CopyScreen
'下雪,這個函數寫得太粗糙了,大夥湊和看吧,反正不是我寫的:)
fSnow
End Sub
'編寫表單的滑鼠按下代碼,以退出程式:
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Unload Me
End Sub

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.