【VB开源代码栏目提醒】:以下是网学会员为您推荐的VB开源代码-用VB编写看图程序 - 计算机教材,希望本篇文章对您学习有所帮助。
用
VB编写看图程序 云飞 2001年 7期 ACDSee之类的看图
程序,有没有想过自己编写一个看图程序呢?用
VB来实现这一想法是非常简便的。
怎么样?Let’s Go! 1 一、界面
设计 Form1上放置一个水平滚动条、一个垂直滚动条和一个图片框Picture1。
Picture1作为浏览图片的窗口,其大小固定。
点击Picture1,再拖入一个图像框Image1(将Image1约束在Picture1中)。
设置Image1的Stretch属性为False,使它能自动适应图片大小。
点击“工程→部件”,选中Microoft Common Dialog Corntrol 6.0,工具箱中会出现对话框控件,拖入窗体,设置其Filter属性为“.bmp|.bmp|.gif|.gif|.jpg|.jpg|.|.”。
最后,再加入两个命令按钮Command1和Command2,其Caption属性分别设为“打开”和“退出”。
1 二、程序
代码 Option Explicit Private Sub Command1_Click() On Error GoTo error CommonDialog1.ShowOpen If CommonDialog1.FileName“” Then Image1.PictureLoadPicture(CommonDialog1.FileName) Image1 VScroll1.Value0 HScroll1.Value0 Check’比较图片与图片框的大小 End If Error: End Sub Private Sub Command2_Click() End End Sub Private Sub Form_Resize() Picture1.WidthForm1.ScaleWidth-1500 Picture1.Top0 Picture1.HeightForm1.ScaleHeight-HScroll1.Height Command1.LeftForm1.Width-1250 Command2.LeftForm1.Width-1250 HScroll1.WidthPicture1.Width HScroll1.TopPicture1.Height VScroll1.HeightPicture1.Height VScroll1.LeftPicture1.Width check End Sub Private Sub HScroll1_Change() Image1.Left-HScroll1.Value End Sub Private Sub HScroll1_Scroll() Image1.Left-HScroll1.Value End Sub Private Sub VScroll1_Change() Image1.Top-VScroll1.Value End Sub Private Sub VScroll1_Scroll() Image1.Top-VScroll1.Value End Sub Sub check() If Image1.Height