1.首先建立一个基于Microsoft .NET Framework 2.0以上的VB.NET解决方案。
10年积累的网站制作、成都网站设计经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先制作网站后付款的网站建设流程,更有绿春免费网站建设让你可以放心的选择与我们合作。
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 开发的,若有错误请参考请他方法进行修改
你要确定每个状态的大小是一樱蔽样的才可以:
Public Bitmap CutImage(ByVal start As Point, ByVal end As Point, ByVal b As Bitmap)
Dim f As New Bitmap(end.X - start.X + 1, end.Y - start.Y + 1)
For i As Integer = start.X To end.X + 1
For j As Integer = start.Y To end.Y + 1
Dim c As Color = b.GetPixel(i, j)
f.SetPixel(i - start.X, j - start.Y, c)
Next
Next
Return f
End Sub
这个函数就可以用于裁纳颂丛剪图像,返回裁剪后的图像,start是开始裁剪的位置,end是结束裁剪的位置,b是要裁剪的图像,假如你的这些洞樱按钮每个宽30,高20,你就可以用
PictureBox1.Image = CutImage(New Point(第n - 1个按钮 * 30, 0), New Point(第n个按钮 * 30, 20), 按钮存在的位图)
一般Graphics都是通过控件比如Panel,PictureBox来进行绘制的,
PictureBox pb= new PictureBox();
pb.Paint += new System.Windows.Forms.PaintEventHandler(this.Test_Paint);
void Test_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawImage(....);
g.DrawLine(...);
}
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'建仔谈败立新的系统进程
Dim process As New System.Diagnostics.Process()
If RadioButton1.Checked Then
'设置文件名,此处为图片的真实路径+文件名
process.StartInfo.FileName = "c:\a.bmp"
'设置进程运行参数
process.StartInfo.Arguments = "rundll32.exe shimgvw.dll"
Else
process.StartInfo.FileName = "mspaint.exe"
process.StartInfo.Arguments = "c:\a.bmp"
End If
'此项为是否使用Shell执行程序,因系统默认为true,此项也可不设,但若设置必须为true
'process.StartInfo.UseShellExecute = True
侍举 '此处可以更改进念颤程所打开窗体的显示样式,可以不设
'process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
process.Start()
process.Close()
End Sub