用户登录  |  用户注册
首 页源码下载网络学院最新源码源码排行屏蔽广告
当前位置:新兴网络 > 源码下载 > VB源码 > 控件组件 > VB vbMHWB v1.2.1.6浏览器控件源码_VB WebBrowser加强版控件 > frmFindText.frm
loading...复制代码
VERSION 5.00
Begin VB.Form frmFindText 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Find"
   ClientHeight    =   2670
   ClientLeft      =   4725
   ClientTop       =   2190
   ClientWidth     =   5145
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   178
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   343
   Begin VB.CommandButton Command1 
      Caption         =   "Test FindAnyTextMatchCallback event"
      Height          =   495
      Left            =   120
      TabIndex        =   10
      Top             =   2040
      Width           =   4815
   End
   Begin VB.CheckBox chkSearchAllFrames 
      Caption         =   "In All Frames"
      Height          =   255
      Left            =   120
      TabIndex        =   9
      Top             =   1560
      Width           =   2775
   End
   Begin VB.TextBox txtFind 
      Height          =   375
      Left            =   120
      TabIndex        =   0
      Text            =   "google"
      Top             =   120
      Width           =   2775
   End
   Begin VB.ComboBox comFindColor 
      Height          =   315
      ItemData        =   "frmFindText.frx":0000
      Left            =   3120
      List            =   "frmFindText.frx":01A5
      Style           =   2  'Dropdown List
      TabIndex        =   7
      Top             =   1440
      Width           =   1815
   End
   Begin VB.CheckBox chkSearchAndHighlight 
      Caption         =   "Search and highligh matches"
      Height          =   300
      Left            =   120
      TabIndex        =   6
      Top             =   1320
      Width           =   2775
   End
   Begin VB.OptionButton optFindUp 
      Caption         =   "Search Upward"
      Height          =   255
      Left            =   3120
      TabIndex        =   5
      Top             =   870
      Width           =   1695
   End
   Begin VB.OptionButton optFindDown 
      Caption         =   "Search Downward"
      Height          =   255
      Left            =   3120
      TabIndex        =   4
      Top             =   600
      Value           =   -1  'True
      Width           =   1695
   End
   Begin VB.CheckBox chkMatchCase 
      Caption         =   "Match case"
      Height          =   300
      Left            =   120
      TabIndex        =   3
      Top             =   870
      Width           =   2655
   End
   Begin VB.CheckBox chkMatchWholeWord 
      Caption         =   "Match whole word only"
      Height          =   300
      Left            =   120
      TabIndex        =   2
      Top             =   600
      Width           =   2655
   End
   Begin VB.CommandButton cmdCloseFind 
      Cancel          =   -1  'True
      Caption         =   "Close"
      Height          =   375
      Left            =   4080
      TabIndex        =   8
      Top             =   120
      Width           =   975
   End
   Begin VB.CommandButton cmdFind 
      Caption         =   "Find"
      Height          =   375
      Left            =   3000
      TabIndex        =   1
      Top             =   120
      Width           =   975
   End
End
Attribute VB_Name = "frmFindText"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private bResult As Boolean
Private bNewSearch As Boolean

'To be called from other forms
Public Sub CloseFindDlg()
    On Error GoTo CloseFindDlg_Error

    Me.Caption = "Find"
    bNewSearch = True
    Me.Hide
    Exit Sub
CloseFindDlg_Error:
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure CloseFindDlg of Form frmFindText"
End Sub

Private Sub cmdCloseFind_Click()
    CloseFindDlg
End Sub

Private Sub cmdFind_Click()
    On Error GoTo cmdFind_Click_Error
    
    Dim sText As String
    Dim bMWW As Boolean
    Dim bMC As Boolean
    Dim bDirDown As Boolean
    Dim bResult As Boolean
    Dim lResult As Long
    Dim sColor As String
    
    'get the text to search for
    sText = txtFind.Text
    If LenB(sText) = 0 Then Exit Sub
        
        'Set up flags
        If chkMatchWholeWord.Value = vbChecked Then bMWW = True
        If chkMatchCase.Value = vbChecked Then bMC = True
        If optFindDown.Value = True Then bDirDown = True
        If LenB(comFindColor.Text) > 0 Then
            sColor = Me.comFindColor.Text
        Else
            sColor = "greenyellow"
        End If
        
        'Search, accounts for frames
        bResult = False
        If chkSearchAndHighlight.Value = vbChecked Then
            If chkSearchAllFrames.Value = vbChecked Then 'all frames
                frmMain.vbWB1.FindAndHighlightAllTextFrames frmMain.iCur, sText, bMWW, bMC, sColor, lResult
            Else 'only active document (could be a frame)
                frmMain.vbWB1.FindAndHighlightAllText frmMain.iCur, sText, bMWW, bMC, sColor, lResult
            End If
            MsgBox "Found " & CStr(lResult) & " Matches.", vbOKOnly + vbInformation
        Else
            frmMain.vbWB1.FindTextSimple frmMain.iCur, sText, bDirDown, bMWW, bMC, True, bResult
            If bResult = False Then MsgBox "No Matches Found", vbOKOnly + vbInformation
        End If
    
    Exit Sub
cmdFind_Click_Error:
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdFind_Click of Form frmFindText"
End Sub

Private Sub Command1_Click()

    On Error GoTo Command1_Click_Error
    Dim bResult As Boolean
    Dim sText As String
    
    sText = txtFind.Text
    frmMain.vbWB1.FindAnyTextMatch frmMain.iCur, sText, CBool(chkMatchWholeWord.Value), CBool(chkMatchCase.Value), bResult
    MsgBox "Result " & CStr(bResult)
    
    Exit Sub
Command1_Click_Error:
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Command1_Click of Form frmFindText"
End Sub

Private Sub Form_Load()
    On Error GoTo Form_Load_Error
    
    bNewSearch = True
    comFindColor.ListIndex = 0
    Exit Sub
Form_Load_Error:
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_Load of Form frmFindText"
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

    On Error GoTo Form_QueryUnload_Error

        If UnloadMode = vbFormControlMenu Then
            Cancel = True
            CloseFindDlg
            Exit Sub
        End If

    Exit Sub
Form_QueryUnload_Error:
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_QueryUnload of Form frmFindText"
End Sub

Private Sub txtFind_KeyPress(KeyAscii As Integer)

    On Error GoTo txtFind_KeyPress_Error

    If KeyAscii = 13 Then cmdFind_Click

    Exit Sub
txtFind_KeyPress_Error:
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure txtFind_KeyPress of Form frmFindText"
End Sub