📄 frmfind.frm
字号:
VERSION 5.00
Begin VB.Form frmFind
BorderStyle = 3 'Fixed Dialog
Caption = "查找"
ClientHeight = 2535
ClientLeft = 45
ClientTop = 330
ClientWidth = 6270
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2535
ScaleWidth = 6270
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton Command4
Caption = "全部替换"
Height = 375
Left = 4650
TabIndex = 14
Top = 2040
Width = 1125
End
Begin VB.ComboBox Combo2
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 330
ItemData = "frmFind.frx":0000
Left = 1320
List = "frmFind.frx":000D
Style = 2 'Dropdown List
TabIndex = 11
Top = 1080
Width = 1215
End
Begin VB.Frame Frame1
Caption = "查找设置:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1695
Left = 4320
TabIndex = 7
Top = 120
Width = 1815
Begin VB.CheckBox Check1
Caption = "选定区域"
Height = 315
Index = 3
Left = 240
TabIndex = 13
Top = 1320
Width = 1395
End
Begin VB.CheckBox Check1
Caption = "模式匹配"
Height = 315
Index = 2
Left = 240
TabIndex = 10
Top = 960
Width = 1395
End
Begin VB.CheckBox Check1
Caption = "全字匹配"
Height = 315
Index = 1
Left = 240
TabIndex = 9
Top = 600
Width = 1395
End
Begin VB.CheckBox Check1
Caption = "区分大小写"
Height = 315
Index = 0
Left = 240
TabIndex = 8
Top = 240
Width = 1395
End
End
Begin VB.CommandButton Command3
Cancel = -1 'True
Caption = "取消(&C)"
Height = 375
Left = 2880
TabIndex = 6
Top = 2040
Width = 1125
End
Begin VB.CommandButton Command2
Caption = "替换(&H)"
Height = 375
Left = 1680
TabIndex = 5
Top = 2040
Width = 1125
End
Begin VB.CommandButton Command1
Caption = "查找下一个(&N)"
Default = -1 'True
Height = 375
Left = 120
TabIndex = 4
Top = 2040
Width = 1485
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 1320
TabIndex = 2
Text = "Text1"
Top = 600
Width = 2865
End
Begin VB.ComboBox Combo1
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 330
Left = 1320
TabIndex = 0
Top = 120
Width = 2865
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "搜索方向:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 120
TabIndex = 12
Top = 1080
Width = 1050
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "替换内容:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 120
TabIndex = 3
Top = 600
Width = 1050
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "查找内容:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 120
TabIndex = 1
Top = 120
Width = 1050
End
End
Attribute VB_Name = "frmFind"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public 是替换 As Boolean
Private Sub Check1_Click(Index As Integer)
Select Case Index
Case 0
Find1.区分大小写 = IIf(Check1(Index).Value = 0, False, True)
Case 1
Find1.全字匹配 = IIf(Check1(Index).Value = 0, False, True)
Case 2
Find1.模式匹配 = IIf(Check1(Index).Value = 0, False, True)
Case 3
Find1.选定区域 = IIf(Check1(Index).Value = 0, False, True)
End Select
End Sub
Private Sub Combo1_Change()
Call Combo1_Click
End Sub
Private Sub Combo1_Click()
Find1.Find_Str = Combo1.Text
If Combo1.Text <> "" Then
Command1.Enabled = True
Else
Command1.Enabled = False
End If
End Sub
Private Sub Combo2_Click()
Find1.查找方向 = Combo2.ItemData(Combo2.ListIndex)
End Sub
Private Sub Command1_Click()
fMainForm.Find_Next
End Sub
Private Sub Command2_Click()
If Command2.Caption = "替换(&H)" Then
Command2.Caption = "查找(&F)"
Me.Caption = "替换"
是替换 = True
Else
Command2.Caption = "替换(&H)"
Me.Caption = "查找"
是替换 = False
End If
Text1.Visible = 是替换
Label2.Visible = 是替换
Command4.Visible = 是替换
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim retValue As Long
retValue = SetWindowPos(Me.hwnd, HWND_TOPMOST, Me.CurrentX, Me.CurrentY, 424, 194, SWP_SHOWWINDOW) '设置窗口总在最上层.
Combo1.Text = fMainForm.GetSelText() '调用主窗口的自定义方法, 获取文本框中选定的文本.
If Combo1.Text <> "" Then
Combo1.AddItem Combo1.Text '如果有选定的文本, 则
Else
Combo1.Text = Find1.Find_Str '如果没有选定的文本, 将上次查找内容设为本次查找内容.
End If
Text1.Text = Find1.Replace_str '将上次替换文本, 设为本次替换文本
If 是替换 Then
Me.Caption = "替换"
Command2.Caption = "查找"
Else
Me.Caption = "查找"
End If
Text1.Visible = 是替换
Label2.Visible = 是替换
Command4.Visible = 是替换
Combo2.ListIndex = Find1.查找方向
Check1(0).Value = IIf(Find1.区分大小写, 1, 0)
Check1(1).Value = IIf(Find1.全字匹配, 1, 0)
Check1(2).Value = IIf(Find1.模式匹配, 1, 0)
Check1(3).Value = IIf(Find1.选定区域, 1, 0)
Find1.Where = 1
fMainForm.mnuEditFind.Enabled = False
fMainForm.mnuEditFindNext.Enabled = False
fMainForm.mnuEditReplace.Enabled = False
Call Combo1_Click
End Sub
Private Sub Form_Unload(Cancel As Integer)
fMainForm.mnuEditFind.Enabled = True
fMainForm.mnuEditFindNext.Enabled = True
fMainForm.mnuEditReplace.Enabled = True
End Sub
Private Sub Text1_Change()
Find1.Replace_str = Text1.Text
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -