怎么用VB.NET2005编程实现在桌面随机位置显示随机不同的图片,望高手帮忙
就是能在电脑桌面不停着显示不同的图片,图片很小,过一段时间桌面全部是图片,点击下鼠标又全部消失,程序原码,谢谢...
就是能在电脑桌面不停着显示不同的图片,图片很小,过一段时间桌面全部是图片,点击下鼠标又全部消失,程序原码,谢谢
展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
展开全部
Dim Ran1 As New Random()
Public jpgfile As New List(Of Bitmap)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Timer1.Interval = 50
Ran1 = New Random(Date.Now.ToOADate)
For Each i As IO.FileInfo In New IO.DirectoryInfo("I:\我的文档\Images\1280X800").GetFiles("*.jpg")
Dim pic As New Bitmap(i.FullName)
‘ jpgfile.Add(New Bitmap(pic, pic.Size.Width / 8, pic.Size.Height / 8))’将图片同比缩小到8分之一。
Next
Me.BackColor = SystemColors.Control
Me.TransparencyKey = SystemColors.Control
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.WindowState = FormWindowState.Maximized
‘窗体全屏,并设置无边框窗体。
Timer1.Enabled = True
End Sub
在Timer1_Tick的过程中
Me.CreateGraphics.DrawImage(pic, New Point(x, y))
在窗体的以x、y为左上角位置绘制图片。xy用random随机数随机产生,上下值分别在0-me的大小宽高之间。
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim n As Integer = Ran1.Next(0, jpgfile.Count - 1)
Dim pic As Bitmap = jpgfile(n)
Dim x As Integer = Ran1.Next(50, Me.Size.Width - pic.Size.Width - 50)
Dim y As Integer = Ran1.Next(50, Me.Size.Height - pic.Size.Height - 50)
Me.CreateGraphics.DrawImage(pic, New Point(x, y))
End Sub
Public jpgfile As New List(Of Bitmap)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Timer1.Interval = 50
Ran1 = New Random(Date.Now.ToOADate)
For Each i As IO.FileInfo In New IO.DirectoryInfo("I:\我的文档\Images\1280X800").GetFiles("*.jpg")
Dim pic As New Bitmap(i.FullName)
‘ jpgfile.Add(New Bitmap(pic, pic.Size.Width / 8, pic.Size.Height / 8))’将图片同比缩小到8分之一。
Next
Me.BackColor = SystemColors.Control
Me.TransparencyKey = SystemColors.Control
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.WindowState = FormWindowState.Maximized
‘窗体全屏,并设置无边框窗体。
Timer1.Enabled = True
End Sub
在Timer1_Tick的过程中
Me.CreateGraphics.DrawImage(pic, New Point(x, y))
在窗体的以x、y为左上角位置绘制图片。xy用random随机数随机产生,上下值分别在0-me的大小宽高之间。
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim n As Integer = Ran1.Next(0, jpgfile.Count - 1)
Dim pic As Bitmap = jpgfile(n)
Dim x As Integer = Ran1.Next(50, Me.Size.Width - pic.Size.Width - 50)
Dim y As Integer = Ran1.Next(50, Me.Size.Height - pic.Size.Height - 50)
Me.CreateGraphics.DrawImage(pic, New Point(x, y))
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询