
上QQ阅读APP看本书,新人免费读10天
设备和账号都新为新人
3.2 机械振动计算程序常用的用户界面的重要工具——通用对话框
Visual Basic提供通用对话框(CommonDialog)工具,可使用户在窗体上创建6种标准对话框,分别为“打开(Open)”、“另存为(Save As)”、“颜色(Color)”、“字体(Font)”、“打印机(Printer)”和“帮助(Help)”对话框。
工具箱里添加通用对话框的方法:
① 在工具箱上右键单击,即可在工具箱边上弹出一个快捷菜单,如图3.1所示。

图3.1 快捷菜单
② 选择快捷菜单中的“部件”命令打开部件对话框,如图 3.2所示。

图3.2 部件对话框
在部件标签中选定Microsoft Common Dialog control 6.0。最后选择单击按钮。
工具箱中即会出现一通用对话框(CommonDialog)小图标。即成功添加了通用对话框。如图3.3所示。

图3.3 添加了通用对话框
把通用对话框加到工具箱后,就可像使用标准控件一样,也能够把它添加到窗体中,如图3.4所示。

图3.4 通用对话框添加到窗体中
在设计状态,它的图标显示在窗体上,但在程序运行时,该图标是不显示的。直到在程序中用Action属性或Show方法才激活调出相应的对话框。
通用对话框布置到窗体上,就可到属性窗口中设置属性,如图3.5所示。

图3.5 在属性窗口中设置属性
也可以在通用对话框控件“属性”对话框中设置。打开“属性”对话框的方法是对窗体上的通用对话框控件单击右键,在弹出的快捷菜单中选择“属性”命令,如图3.6所示。

图3.6 弹出的快捷菜单中选择“属性”命令
通用对话框控件“属性”对话框中有5个标签,对不同类型的对话框设置属性,就要选择不同的标签。如图3.7所示。

图3.7 通用对话框控件“属性”对话框
例如要对“打印”对话框设置,就选定打印标签。