重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
窗体上放一个PictureBox,两个CommandButton,一个FileListBox
成都创新互联公司专注于企业全网营销推广、网站重做改版、安宁网站定制设计、自适应品牌网站建设、HTML5建站、商城网站开发、集团公司官网建设、外贸营销网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为安宁等各大城市提供网站开发制作服务。
Private Sub Command1_Click()
If File1.ListIndex = 0 Then
ShowPic File1.ListCount - 1
Else
ShowPic File1.ListIndex - 1
End If
End Sub
Private Sub Command2_Click()
If File1.ListIndex = File1.ListCount - 1 Then
ShowPic 0
Else
ShowPic File1.ListIndex + 1
End If
End Sub
Private Sub Form_Load()
File1.Visible = False
File1.Pattern = "*.jpg;*.gif" '可以浏览的文件类型,使用分号隔开
File1.Path = App.Path '改成你需要浏览的目录,比如"C:\Pic"
If File1.ListCount 1 Then '目录中图片在两张以上可以浏览
ShowPic 0
Exit Sub
ElseIf File1.ListCount = 1 Then '目录中只有一张图片时只显示这一张
ShowPic 0
End If
Command1.Enabled = False
Command2.Enabled = False
End Sub
Private Sub ShowPic(Index As Long)
File1.ListIndex = Index
Picture1.Picture = LoadPicture(File1.Path "\" File1.List(Index))
End Sub
如果对您有帮助,请记得采纳为满意答案,谢谢!祝您生活愉快!
vaela
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 开发的,若有错误请参考请他方法进行修改
转换成位图肯定是可以浏览的,WMF文件没试过。
你可以将图片以二进制形式存储在数据库中,如果是SQL Server,对应字段的类型应该是image。
我说选把打开多个图片路径加载到一个listbox里,利用listbox写代码
Private Sub picbox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If ListBox1.SelectedIndex = count Then
Try
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
Catch
ListBox1.SelectedIndex = 0
End Try
End If
picbox.Image = ListBox1.SelectedItem.ToString
End Sub
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