⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmsearch.frm

📁 NOPAD的VB6原碼,寫的還蠻齊全的,請參考
💻 FRM
📖 第 1 页 / 共 2 页
字号:
VERSION 5.00
Begin VB.Form frmSearch 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   2460
   ClientLeft      =   2475
   ClientTop       =   1425
   ClientWidth     =   5610
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   2460
   ScaleWidth      =   5610
   ShowInTaskbar   =   0   'False
   Begin VB.ComboBox cboReplace 
      Height          =   315
      Left            =   1200
      TabIndex        =   1
      Top             =   570
      Width           =   3045
   End
   Begin VB.CommandButton btnAll 
      Caption         =   "Replace All"
      Height          =   315
      Left            =   4440
      TabIndex        =   8
      Top             =   1590
      Width           =   1065
   End
   Begin VB.CommandButton btnReplace 
      Caption         =   "&Replace"
      Height          =   315
      Left            =   4440
      TabIndex        =   7
      Top             =   1140
      Width           =   1065
   End
   Begin VB.CommandButton btnCancel 
      Cancel          =   -1  'True
      Caption         =   "&Cancel"
      Height          =   315
      Left            =   4440
      TabIndex        =   6
      Top             =   570
      Width           =   1065
   End
   Begin VB.CommandButton btnNext 
      Caption         =   "Find &Next"
      Default         =   -1  'True
      Height          =   315
      Left            =   4440
      TabIndex        =   5
      Top             =   120
      Width           =   1065
   End
   Begin VB.ComboBox cboFind 
      Height          =   315
      Left            =   960
      TabIndex        =   0
      Top             =   120
      Width           =   3285
   End
   Begin VB.PictureBox pnlOptions 
      BackColor       =   &H00C0C0C0&
      Height          =   1305
      Left            =   120
      ScaleHeight     =   1245
      ScaleWidth      =   4065
      TabIndex        =   10
      Top             =   1080
      Width           =   4125
      Begin VB.Frame fraSearch 
         Caption         =   "Search"
         Height          =   1155
         Left            =   30
         TabIndex        =   11
         Top             =   60
         Width           =   1935
         Begin VB.OptionButton optCurDoc 
            BackColor       =   &H00C0C0C0&
            Caption         =   "Current &Document"
            Height          =   255
            Left            =   120
            TabIndex        =   2
            Top             =   330
            Value           =   -1  'True
            Width           =   1695
         End
         Begin VB.OptionButton optAllDocs 
            Caption         =   "&All Documents"
            Height          =   255
            Left            =   120
            TabIndex        =   12
            Top             =   750
            Width           =   1695
         End
      End
      Begin VB.CheckBox chkMatch 
         Caption         =   "&Match Case"
         Height          =   225
         Left            =   2100
         TabIndex        =   4
         Tag             =   "4"
         Top             =   840
         Width           =   1185
      End
      Begin VB.CheckBox chkWholeWord 
         Caption         =   "Find Whole &Word Only"
         Height          =   225
         Left            =   2100
         TabIndex        =   3
         Tag             =   "2"
         Top             =   420
         Width           =   1965
      End
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "Replace With:"
      Height          =   195
      Index           =   2
      Left            =   120
      TabIndex        =   13
      Top             =   630
      Width           =   1020
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "Find What:"
      Height          =   195
      Index           =   0
      Left            =   120
      TabIndex        =   9
      Top             =   180
      Width           =   780
   End
End
Attribute VB_Name = "frmSearch"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public StartForm As String
Public StartPos As Long
Public CurrentDocIndex As Integer

Dim AForms() As Form
Dim AFormsCount As Integer

Public Sub DestroyFormArray()

On Error Resume Next

For x = 0 To AFormsCount
    Set AForms(x) = Nothing
Next x

'init AFormsCount value to zero
'this must come after DestroyFormArray since that method uses this
'number for its loop
AFormsCount = 0

End Sub


Public Sub Init()

'assign active form's caption (filename) to frmSearch's StartForm property
StartForm = frmMain.ActiveForm.Caption

'assign current cursor pos as new starting pos
StartPos = frmMain.ActiveForm.Text1.SelStart

'check for highlighted text and set Replace btn state accordingly
If frmMain.ActiveForm.Text1.SelLength > 0 Then
    btnReplace.Enabled = True
Else
    btnReplace.Enabled = False
End If

'init AForms()
If optCurDoc.Value = True Then
    optCurDoc_Click
Else
    optAllDocs_Click
End If

End Sub

Private Sub btnAll_Click()

Dim Counter As Integer
Counter = 0

'turn Stop button on
frmMain.Toolbar.Buttons("Stop").Image = "StopOn"

'init search to begin from current point, this will cause a
'rebuild of AForms() - must use this to get Replace All button
'to work properly
Init

'init frmMain.MsgMode to tell find btnNext_Click() not to display
'its default message that "the specified region has been searched"
'this proc has its own msg informing user of # of replacements made
frmMain.ReplaceFlag = True

'init usermsg var (return from dialog)
frmMain.UserMsgChoice = ""

'loop through all documents in AForms()
Do While Not frmMain.UserMsgChoice = "Cancel"
        
    'if there is text highlighted if the active form
    If frmMain.ActiveForm.Text1.SelLength > 0 Then
        
        If Not frmMain.UserMsgChoice = "All" Then
            
            'if search form is visible, hide it
            If Me.Visible Then
                'make search form not topmost
                success% = SetWindowPos(frmSearch.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)
                
                'hide search form
                Me.Hide
            End If
            
            'init frmMsg
            frmMain.MsgMode = "Search"
            
            'show frmMsg
            frmMsg.Show 1
            
            'proc frmMsg
            Select Case frmMain.UserMsgChoice
            
            Case "Yes", "All"
                frmMain.ActiveForm.Text1.SelText = cboReplace.Text
                Counter = Counter + 1
                                            
            Case "Cancel"
                GoTo frmSearchbtnAllClickJump1
            
            End Select
            
        Else
            
            'replace text and increment replacement counter
            frmMain.ActiveForm.Text1.SelText = cboReplace.Text
            Counter = Counter + 1
        
        End If
    
    End If
    
    'find next instance of search string
    btnNext_Click

'process other windows calls (such as pressing the stop button)
DoEvents

Loop

frmSearchbtnAllClickJump1:

'msg user on replacements
MsgBox "There were" & Str$(Counter) & " replacements made.", 64, "Replacements Confirmed"

'show search form
frmSearch.Show

'make search form topmost
success% = SetWindowPos(frmSearch.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)

frmMain.ReplaceFlag = False

'turn Stop button off
frmMain.Toolbar.Buttons("Stop").Image = "StopOff"

End Sub

Private Sub btnCancel_Click()

'make form not topmost
success% = SetWindowPos(frmSearch.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)

'hide form

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -