📄 frmsyslog.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "Richtx32.ocx"
Begin VB.Form frmSysLog
BorderStyle = 3 'Fixed Dialog
Caption = "系统日志"
ClientHeight = 5595
ClientLeft = 45
ClientTop = 330
ClientWidth = 7860
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "frmSysLog.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5595
ScaleWidth = 7860
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin MSComDlg.CommonDialog CommonDialog1
Left = 1860
Top = 1605
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin RichTextLib.RichTextBox RichTextBox1
Height = 4200
Left = 180
TabIndex = 0
Top = 135
Width = 6240
_ExtentX = 11007
_ExtentY = 7408
_Version = 393217
BackColor = -2147483629
BorderStyle = 0
Enabled = -1 'True
ReadOnly = -1 'True
ScrollBars = 2
TextRTF = $"frmSysLog.frx":030A
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.CommandButton cmdButton
Caption = "打印(&P)"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 645
Index = 2
Left = 2970
Picture = "frmSysLog.frx":03A7
Style = 1 'Graphical
TabIndex = 3
Top = 4785
Width = 1095
End
Begin VB.CommandButton cmdButton
Cancel = -1 'True
Caption = "关闭(&C)"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 645
Index = 3
Left = 4350
Picture = "frmSysLog.frx":04A9
Style = 1 'Graphical
TabIndex = 4
Top = 4785
Width = 1095
End
Begin VB.CommandButton cmdButton
Caption = "清除(&D)"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 645
Index = 0
Left = 210
Picture = "frmSysLog.frx":07ED
Style = 1 'Graphical
TabIndex = 1
Top = 4740
UseMaskColor = -1 'True
Width = 1095
End
Begin VB.CommandButton cmdButton
Caption = "记录(&A)..."
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 645
Index = 1
Left = 1455
Picture = "frmSysLog.frx":08EF
Style = 1 'Graphical
TabIndex = 2
Top = 4755
UseMaskColor = -1 'True
Width = 1095
End
End
Attribute VB_Name = "frmSysLog"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'记录设计时的窗体大小
Dim InitialHeight As Integer
Dim InitialWidth As Integer
Const iSpace As Integer = 150 '界面的间距
Private Sub cmdButton_Click(Index As Integer)
Select Case Index
Case 0 'cmdDeleteAll
Call cmdDeleteAll
Case 1 'cmdAddNew
Call cmdAddNew
Case 2 'cmdPrint
Call cmdPrint
Case 3
Unload Me
End Select
End Sub
Private Sub cmdDeleteAll()
Dim ret As VbMsgBoxResult
ret = vbNo
ret = MsgBox("清除所有的系统日志信息。是吗?", vbInformation + vbYesNo, Me.Caption)
If ret = vbYes Then
'clear the system.log
Call ClearUpSystemLog
RichTextBox1.Text = ""
RichTextBox1.Refresh
RichTextBox1.SetFocus
End If
End Sub
Private Sub cmdAddNew()
Dim frm As frmAddToLog
Dim ret As String
Set frm = New frmAddToLog
Load frm
frm.Show vbModal
ret = frm.sysInfo
If ret = "" Then
Exit Sub
End If
'write sysinfo to "system.log"
Call WriteToLog(frm.sysInfo)
'read sysinfo
Call GetSystemLog
RichTextBox1.SetFocus
RichTextBox1.SelStart = Len(RichTextBox1.Text)
End Sub
Private Sub cmdPrint()
On Error GoTo ErrHandler
CommonDialog1.Flags = cdlPDReturnDC + cdlPDNoPageNums
CommonDialog1.CancelError = True
If RichTextBox1.SelLength = 0 Then
CommonDialog1.Flags = CommonDialog1.Flags + cdlPDAllPages
Else
CommonDialog1.Flags = CommonDialog1.Flags + cdlPDSelection
End If
CommonDialog1.ShowPrinter
RichTextBox1.SelPrint CommonDialog1.hDC
Exit Sub
ErrHandler:
' ErrMessageBox Me.Name & ":cmdPrint", Me.Caption
' '显示错误日志
' Call GetSystemLog
End Sub
Private Sub Form_Load()
On Error GoTo ErrHandler
Screen.MousePointer = 11
'记录窗体大小
InitialWidth = Me.Width
InitialHeight = Me.Height
'第一次启动窗体时,将窗体限制在fMainForm内
Me.Left = 0
Me.Top = 0
Me.Width = fMainForm.ScaleWidth
Me.Height = fMainForm.ScaleHeight
'initilize the RichEditBox1
Call GetSystemLog
' '设置清除权限
' If IsArray(curUser) Then
' cmdButton(0).Enabled = curUser(yh_qcrz)
' End If
Screen.MousePointer = 0
Exit Sub
ErrHandler:
Screen.MousePointer = 0
'出错处理
ErrMessageBox Me.Name & ":Form_Load()", Me.Caption
Resume Next
End Sub
Private Sub Form_Resize()
On Error GoTo ErrHandler
'如果窗体是最小化的,则不作计算
If Me.WindowState = vbMinimized Then
Exit Sub
End If
'限制窗体大小
If Me.Width < InitialWidth Then Me.Width = InitialWidth
If Me.Height < InitialHeight Then Me.Height = InitialHeight
'set datagrid1
RichTextBox1.Left = 0 'iSpace
RichTextBox1.Top = 0 'iSpace
RichTextBox1.Width = Me.ScaleWidth '- RichTextBox1.Left - iSpace
RichTextBox1.Height = Me.ScaleHeight - RichTextBox1.Top - 2 * iSpace - cmdButton(0).Height
'设置buttons的位置
Dim Index As Integer
cmdButton(0).Left = iSpace
cmdButton(0).Top = Me.ScaleHeight - iSpace - cmdButton(0).Height
For Index = 1 To cmdButton.Count - 2
cmdButton(Index).Left = cmdButton(Index - 1).Left + cmdButton(Index - 1).Width
cmdButton(Index).Top = cmdButton(0).Top
Next Index
Index = cmdButton.Count - 1 '最后一个按钮
cmdButton(Index).Left = Me.ScaleWidth - iSpace - cmdButton(Index).Width
cmdButton(Index).Top = cmdButton(0).Top
Exit Sub
ErrHandler:
'出错处理
ErrMessageBox Me.Name & ":Form_Resize()", Me.Caption
End Sub
Private Sub GetSystemLog()
Dim info As String
info = ReadFromLog()
RichTextBox1.Text = info
RichTextBox1.Refresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -