📄 frmdialog.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Begin VB.Form frmDialog
BackColor = &H0080C0FF&
BorderStyle = 3 'Fixed Dialog
Caption = "参数设置"
ClientHeight = 2295
ClientLeft = 2760
ClientTop = 3750
ClientWidth = 6030
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2295
ScaleWidth = 6030
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.PictureBox picColor
BackColor = &H008080FF&
Height = 375
Left = 1920
ScaleHeight = 315
ScaleWidth = 2235
TabIndex = 8
Top = 480
Width = 2295
End
Begin MSComDlg.CommonDialog cmdlgOption
Left = 5040
Top = 1560
_ExtentX = 847
_ExtentY = 847
_Version = 393216
CancelError = -1 'True
End
Begin VB.Frame frame1
BackColor = &H0080C0FF&
Caption = "系统设置"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2055
Left = 360
TabIndex = 2
Top = 120
Width = 4095
Begin VB.Label lblFont
Alignment = 2 'Center
BackColor = &H00C0E0FF&
Caption = "欢迎使用"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 1560
TabIndex = 7
Top = 960
Width = 2295
End
Begin VB.Label Label3
BackColor = &H0080C0FF&
Caption = "状态栏字体"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 5
Top = 960
Width = 975
End
Begin VB.Label Label1
BackColor = &H0080C0FF&
Caption = "主窗口背景色"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 3
Top = 480
Width = 1335
End
End
Begin VB.CommandButton CancelButton
Caption = "取消"
Height = 375
Left = 4680
TabIndex = 1
Top = 600
Width = 1215
End
Begin VB.CommandButton OKButton
Caption = "确定"
Height = 375
Left = 4680
TabIndex = 0
Top = 120
Width = 1215
End
Begin VB.Label Label4
Caption = "Label4"
Height = 495
Left = 2400
TabIndex = 6
Top = 1320
Width = 1215
End
Begin VB.Label Label2
Caption = "Label2"
Height = 495
Left = 2400
TabIndex = 4
Top = 1320
Width = 1215
End
End
Attribute VB_Name = "frmDialog"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub Form_Load()
picColor.BackColor = frmMain.BackColor
lblFont.FontBold = frmMain.statMain.Font.Bold
lblFont.FontItalic = frmMain.statMain.Font.Italic
lblFont.FontName = frmMain.statMain.Font.Name
lblFont.FontSize = frmMain.statMain.Font.Size
lblFont.FontUnderline = frmMain.statMain.Font.Underline
End Sub
Private Sub lblFont_Click()
On Error GoTo ON_ERROR2
cmdlgOption.Flags = cdlCFBoth + cdlCFEffects '使对话框列举可用的打印机与屏幕字体,指定对话框使划线、下划线与颜色生效。
cmdlgOption.ShowFont
lblFont.FontBold = cmdlgOption.FontBold
lblFont.FontItalic = cmdlgOption.FontItalic
lblFont.FontName = cmdlgOption.FontName
lblFont.FontSize = cmdlgOption.FontSize
lblFont.FontUnderline = cmdlgOption.FontUnderline
Exit Sub
ON_ERROR2:
Select Case Err.Number
Case 32755
'不执行任何操作,直接退出过程
Exit Sub
Case 380
'没有选择字体
MsgBox "没有选择合适的字体...", vbInformation + vbOKOnly, "没有选择"
Case Else
MsgBox "错误描述:" & Err.Description & vbCrLf & "错误代码:" & Err.Number _
, vbCritical + vbOKOnly, "未知错误"
End Select
End Sub
Private Sub OKButton_Click()
'改变主窗口背景颜色
frmMain.BackColor = picColor.BackColor
'改变主窗口状态栏字体
frmMain.statMain.Font.Bold = picColor.FontBold
frmMain.statMain.Font.Italic = picColor.FontItalic
frmMain.statMain.Font.Name = picColor.FontName
frmMain.statMain.Font.Size = picColor.FontSize
frmMain.statMain.Font.Underline = picColor.FontUnderline
'打印一个规范的字,检验其字体设置的正确性
'frmMain.statMain.Print "员工管理系统"
Unload Me
End Sub
Private Sub picColor_Click()
On Error GoTo ON_error '错误判断
cmdlgOption.CancelError = True '让程式出现一个错误,而不是让按"确定"和"取消"一样
cmdlgOption.ShowColor
picColor.BackColor = cmdlgOption.Color
Exit Sub
ON_error: '出现错误退出
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -