📄 commondialog.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
Caption = "CommonDialog"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 2100
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 2100
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Left = 360
TabIndex = 1
Top = 2760
Width = 1335
End
Begin VB.OptionButton Option1
Caption = "Option1"
Height = 495
Index = 0
Left = 240
TabIndex = 0
Top = 120
Width = 1815
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 240
Top = 1920
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Paint()
Static FlagFormPainted As Integer
' 当第一次画窗体时,
If FlagFormPainted <> True Then
For i = 1 To 5
Load Option1(i) ' 给数组添加 5 个选项按钮。
Option1(i).Top = Option1(i - 1).Top + 350
Option1(i).Visible = True
Next i
Option1(0).Caption = "“打开”对话框" ' 在每个选项按钮上放置标题。
Option1(1).Caption = "“另存为”对话框"
Option1(2).Caption = "“颜色”对话框"
Option1(3).Caption = "“字体”对话框"
Option1(4).Caption = "“打印”对话框"
Option1(5).Caption = "帮助"
Command1.Caption = "显示对话框" ' 标签命令按钮。
FlagFormPainted = True ' 窗体已画完。
End If
End Sub
Private Sub Command1_Click()
If Option1(0).Value Then ' 如果选择打开选箱,
CommonDialog1.ShowOpen ' 显示打开公共对话框。
ElseIf Option1(1).Value Then ' 否则,
CommonDialog1.ShowSave ' 显示 Save 公共对话框。
ElseIf Option1(2).Value Then ' 否则,
CommonDialog1.ShowColor ' 显示 Color 公共对话框。
ElseIf Option1(3).Value Then ' 否则,
CommonDialog1.Flags = cdlCFBoth ' 在使用ShowFont 方法之前必须给 cdlCFBoth,cdlCFPrinterFonts 或 cdlCFScreenFonts置标识属性。
CommonDialog1.ShowFont ' 显示字体公共对话框。
ElseIf Option1(4).Value Then ' 或,
CommonDialog1.ShowPrinter ' 显示打印机公共对话框。
ElseIf Option1(5).Value Then ' 或
CommonDialog1.HelpFile = "mplayer2.hlp"
CommonDialog1.HelpCommand = cdlHelpContents
CommonDialog1.ShowHelp ' 显示 Visual Basic 帮助目录主题。
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -