【VB开源代码栏目提醒】:网学会员在VB开源代码频道为大家收集整理了frmCommonDialog.frm提供大家参考,希望对大家有所帮助!
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmCommonDialog
Caption = "Form1"
ClientHeight = 2955
ClientLeft = 60
ClientTop = 345
ClientWidth = 3765
LinkTopic = "Form1"
ScaleHeight = 2955
ScaleWidth = 3765
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command4
Caption = "打印设置"
Height = 375
Left = 1560
TabIndex = 4
Top = 2280
Width = 1455
End
Begin VB.CommandButton Command3
Caption = "选取字体"
Height = 375
Left = 1560
TabIndex = 3
Top = 1800
Width = 1455
End
Begin VB.CommandButton Command2
Caption = "选取颜色"
Height = 375
Left = 1560
TabIndex = 2
Top = 1320
Width = 1455
End
Begin
VB.CommandButton Command1
Caption = "打开文件"
Height = 375
Left = 1560
TabIndex = 1
Top = 840
Width = 1455
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 240
Top = 720
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.Label Label1
BorderStyle = 1 'Fixed Single
Height = 375
Left = 120
TabIndex = 0
Top = 120
Width = 3495
End
End
Attribute VB_Name = "frmCommonDialog"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
'CancelError 为 True。
On Error GoTo ErrHandler
'设置过滤器。
CommonDialog1.Filter = "所有文件 (*.*)|*.*" _
& "|文本文件 (*.txt)|*.txt|批处理文件 (*.bat)|*.bat"
'指定缺省过滤器。
CommonDialog1.FilterIndex = 2
'显示“打开”对话框。
CommonDialog1.ShowOpen
Me.Label1 = (CommonDialog1.FileName)
Exit Sub
ErrHandler:
'用户按“取消”按钮。
Exit Sub
End Sub
Private Sub Command2_Click()
On Error GoTo ErrHandler
CommonDialog1.ShowColor
Me.Label1 = CommonDialog1.Color
ErrHandler:
Exit Sub
End Sub
Private Sub Command3_Click()
On Error GoTo ErrHandler
CommonDialog1.Flags = 2
CommonDialog1.ShowFont
Me.Label1 = CommonDialog1.FontName _
& CommonDialog1.FontSize
ErrHandler:
Exit Sub
End Sub
Private Sub Command4_Click()
On Error GoTo ErrHandler
CommonDialog1.ShowPrinter
Me.Label1 = CommonDialog1.Copies
ErrHandler:
Exit Sub
End Sub