1.首先建立一个基于Microsoft .NET Framework 2.0以上的VB.NET解决方案。
2.在窗体上面添加一个PictureBox控件,并绑定到父容器里面(绑定到父容器的操作可以不去实现)。
3.给PictureBox.Image指定路径,这里以“C:\Windows\Web\Wallpaper\Windows\img0.jpg”为例子,当然这张图片在Windows 7旗舰版下面会有的。
4.添加代码:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Randomize()
Dim xScn As UInteger = My.Computer.Screen.Bounds.Width
Dim yScn As UInteger = My.Computer.Screen.Bounds.Height
ReLine:
Dim xShow As Integer = Int((xScn + 1) * Rnd()) - Me.Width
Dim yShow As Integer = Int((yScn + 1) * Rnd()) - Me.Height
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
PictureBox1.Image = Image.FromFile("C:\Windows\Web\Wallpaper\Windows\img0.jpg")
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
If xShow >= 0 And yShow >= 0 Then
Me.Location = New Point(xShow, yShow)
Else
GoTo ReLine
End If
Me.Show()
End Sub
End Class
5.我是使用 Visual Studio 2012 Ultimate 开发的,若有错误请参考请他方法进行修改