学习VB编程第79天,通用对话框控件

视频加载中...

家里有点事,暂停学习了几天,今天趁中午有点时间学习了一下通用对话框控件。通用对话框控件为ActiveX控件,在默认的控件工具栏没有添加,在使用之前需要先加载到工具箱中。使用时选择“工程”→“部件”命令,在弹出的“部件”对话框中选择Microsoft Common DialogControl 6.0项目,将通用对话框控件加载到工具箱中。

一、通用对话框控件函数

1、CommonDialog1.showopen 显示打开对话框

2、CommonDialog1.showsave 显示另存为对话框

3、CommonDialog1.showcolor显示颜色对话框

4、CommonDialog1.showfont显示字体对话框

5、CommonDialog1.showprint显示打印对话框

6、CommonDialog1.showhelp显示帮助对话框

二、通用对话框控件应用

案例一:制作一个图片打开软件

Windows系统自带的图片软件经常出现预览失败的情况,下面制作一个简单的图片查看软件备用。

(一)思路:CommonDialog1.filename通过Dialog控件选择的文件名。然后利用picture控件和image控件加载图片,通过调整image控件的width和height值调整图片尺寸。补充:使用CommonDialog1.filter函数限制文件类型,CommonDialog1.filter="(*.jpg;)|*.jpg;"

学习VB编程第79天,通用对话框控件

(二)控件:

学习VB编程第79天,通用对话框控件

(三)代码:

Private Sub Command1_Click()

CommonDialog1.ShowOpen

Image1.Picture = LoadPicture(CommonDialog1.FileName)

Picture1.Picture = LoadPicture(CommonDialog1.FileName)

End Sub

Private Sub Timer1_Timer()

If Option1(0).Value = True Then

Image1.Width = 1417.5

Image1.Height = 1984.5

End If

If Option1(1).Value = True Then

Image1.Width = 1984.5

Image1.Height = 2778.3

End If

If Option1(2).Value = True Then

Image1.Width = 3118.5

Image1.Height = 4819.5

End If

If Option1(3).Value = True Then

Image1.Width = 5046.3

Image1.Height = 7200.9

End If

If Option1(4).Value = True Then

Image1.Width = 5783.4

Image1.Height = 8618.4

End If

If Option2.Value = True Then

Image1.Visible = False

Picture1.Visible = True

End If

If Option2.Value = False Then

Image1.Visible = True

Picture1.Visible = False

End If

End Sub

(四)运行效果详见视频。

学习VB编程第79天,通用对话框控件

网络图片

展开阅读全文

页面更新:2024-03-12

标签:控件   对话框   工具箱   文件名   文件类型   部件   图片尺寸   工具栏   函数   思路   加载   中午   图片   科技   软件   视频

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top