日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

雪花屏幕保护程序(VB.ENT)

發布時間:2023/12/20 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 雪花屏幕保护程序(VB.ENT) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?一個雪花屏幕保程序,它顯示一個背景,雪花緩緩落下,單擊鼠標或按任意鍵可以退出,主要用的是Graphics.FillEllipse方法,源碼如下:

Public Class Form1
??? Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

??? Public Sub New()
??????? MyBase.New()

??????? 'This call is required by the Windows Form Designer.
??????? InitializeComponent()

??????? 'Add any initialization after the InitializeComponent() call

??? End Sub

??? 'Form overrides dispose to clean up the component list.
??? Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
??????? If disposing Then
??????????? If Not (components Is Nothing) Then
??????????????? components.Dispose()
??????????? End If
??????? End If
??????? MyBase.Dispose(disposing)
??? End Sub
??? Friend WithEvents Timer1 As System.Windows.Forms.Timer
??? Private components As System.ComponentModel.IContainer

??? 'Required by the Windows Form Designer

??? 'NOTE: The following procedure is required by the Windows Form Designer
??? 'It can be modified using the Windows Form Designer.?
??? 'Do not modify it using the code editor.
??? Friend WithEvents pb1 As System.Windows.Forms.PictureBox
??? <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
??????? Me.components = New System.ComponentModel.Container()
??????? Me.pb1 = New System.Windows.Forms.PictureBox()
??????? Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
??????? Me.SuspendLayout()
??????? '
??????? 'pb1
??????? '
??????? Me.pb1.Location = New System.Drawing.Point(24, 16)
??????? Me.pb1.Name = "pb1"
??????? Me.pb1.Size = New System.Drawing.Size(360, 216)
??????? Me.pb1.TabIndex = 0
??????? Me.pb1.TabStop = False
??????? '
??????? 'Timer1
??????? '
??????? '
??????? 'Form1
??????? '
??????? Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
??????? Me.ClientSize = New System.Drawing.Size(456, 273)
??????? Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.pb1})
??????? Me.Name = "Form1"
??????? Me.Text = "ScreenSaver"
??????? Me.ResumeLayout(False)

??? End Sub

#End Region

??? '雪花的數量
??? Private amount As Integer
??? '每個雪花的橫坐標、縱坐標、下落速度和大小
??? Private snowx() As Integer
??? Private snowy() As Integer
??? Private snowv() As Integer
??? Private snows() As Integer
??? Private r As Random = New Random()

??? Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
??????? '設置窗體的邊框風格為沒有邊框(同時也沒有標題欄)
??????? Me.FormBorderStyle = FormBorderStyle.None
??????? '設置WindowState為Maximized,可以覆蓋任務欄
??????? Me.WindowState = FormWindowState.Maximized

??????? '設置pb1的屬性
??????? pb1.Location = Me.Location
??????? pb1.Size = Me.Size
??????? pb1.BorderStyle = System.Windows.Forms.BorderStyle.None
??????? pb1.SizeMode = PictureBoxSizeMode.StretchImage
??????? pb1.Image = Image.FromFile("背景.tif")

??????? '初始化關于雪花的參數
??????? Snow()
??????? Timer1.Interval = 100
??????? Timer1.Enabled = True
??????? '隱藏光標
??????? Me.Cursor.Hide()
??? End Sub

??? Private Sub Snow()
??????? amount = 1500
??????? ReDim snowx(amount - 1)
??????? ReDim snowy(amount - 1)
??????? ReDim snowv(amount - 1)
??????? ReDim snows(amount - 1)
??????? Dim i As Integer
??????? For i = 0 To amount - 1
??????????? '初始化每個雪花
??????????? InitSnowflake(i)
??????? Next
??? End Sub

??? Private Sub InitSnowflake(ByVal i As Integer)
??????? '注意橫坐標的最大取值為Me.Width-1,否則會發生越界的錯誤
??????? snowx(i) = r.Next(0, Me.Width - 1)
??????? '這是為了使雪花不要過于集中于屏幕底部
??????? snowy(i) = r.Next(0, Me.Height * 3 / 4)
??????? snowv(i) = r.Next(10, 30)
??????? '這是為了使小雪花的數量多一些,大雪花相對少一些
??????? snows(i) = (r.Next(1, 3) * 100 + r.Next(50, 180)) / 101
??? End Sub

??? Private Sub pb1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pb1.Paint
??????? Dim g As Graphics = e.Graphics
??????? Dim i As Integer
??????? For i = 0 To amount - 1
??????????? g.FillEllipse(Brushes.White, snowx(i), snowy(i), snows(i), snows(i))
??????? Next
??? End Sub

??? Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
??????? Dim i As Integer
??????? For i = 0 To amount - 1
??????????? '獲取雪花當前時刻的縱坐標
??????????? snowy(i) += snowv(i)
??????????? If snowy(i) >= Me.Height Then
??????????????? '如果雪花已經下到屏幕底部,則重新對其進行初始化
??????????????? InitSnowflake(i)
??????????? End If
??????? Next
??????? pb1.Invalidate()
??? End Sub

??? Private Sub pb1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pb1.MouseDown
??????? Me.Close()
??? End Sub

??? Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
??????? Me.Close()
??? End Sub

???
End Class

總結

以上是生活随笔為你收集整理的雪花屏幕保护程序(VB.ENT)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。