-
Notifications
You must be signed in to change notification settings - Fork 1
/
FIND.FRM
187 lines (162 loc) · 4.81 KB
/
FIND.FRM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
VERSION 5.00
Begin VB.Form frmFind
BorderStyle = 3 'Fixed Dialog
Caption = "Find..."
ClientHeight = 1665
ClientLeft = 2265
ClientTop = 3060
ClientWidth = 5640
Icon = "Find.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
PaletteMode = 1 'UseZOrder
ScaleHeight = 1665
ScaleWidth = 5640
ShowInTaskbar = 0 'False
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "Salir"
Height = 345
Left = 4185
TabIndex = 4
Top = 1230
Width = 1380
End
Begin VB.CommandButton cmdFind
Caption = "&Buscar"
Default = -1 'True
Enabled = 0 'False
Height = 345
Left = 4185
TabIndex = 3
Top = 825
Width = 1380
End
Begin VB.Frame Frame1
Caption = "Opciones"
Height = 945
Left = 75
TabIndex = 6
Top = 630
Width = 4005
Begin VB.CheckBox chkFind
Caption = "Busqueda exacta"
Height = 225
Index = 1
Left = 165
TabIndex = 2
Top = 585
Width = 3660
End
Begin VB.CheckBox chkFind
Caption = "Solo palabras completas"
Height = 225
Index = 0
Left = 165
TabIndex = 1
Top = 285
Width = 3660
End
End
Begin VB.TextBox txtFind
Height = 300
Left = 75
TabIndex = 0
Top = 285
Width = 4000
End
Begin VB.Label Label1
Caption = "Buscar:"
Height = 195
Left = 75
TabIndex = 5
Top = 60
Width = 1125
End
End
Attribute VB_Name = "frmFind"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim bFound As Boolean
Dim nLastPos As Long
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdFind_Click()
On Error GoTo FindErr
Dim nOptions As Integer, nFoundPos As Long, nFoundLine As Long
If EmptyString(txtFind) Then Exit Sub
nOptions = 0
If chkFind(0) = vbChecked Then nOptions = nOptions + rtfWholeWord
If chkFind(1) = vbChecked Then nOptions = nOptions + rtfMatchCase
If bFound Then
nFoundPos = frmViewFile.RichTextBox.Find(txtFind, nLastPos, , nOptions)
If nFoundPos = -1 Then
' No more text - start from top
nFoundPos = frmViewFile.RichTextBox.Find(txtFind, 0, , nOptions)
End If
Else
' Find the text specified in the TextBox control.
nFoundPos = frmViewFile.RichTextBox.Find(txtFind, 0, , nOptions)
End If
' Show message based on whether the text was found or not.
If nFoundPos = -1 Then
Beep
nLastPos = 0
bFound = False
SetCaption cmdFind, "&Buscar"
Else
' Returns number of line containing found text.
'nFoundLine = frmViewFile.RichTextBox.GetLineFromChar(nFoundPos)
nLastPos = nFoundPos + Len(txtFind)
bFound = True
SetCaption cmdFind, "&Buscar siguiente"
End If
Exit Sub
FindErr:
MsgBox "Error ocurrio en el sistema" & vbCrLf & _
"Error #" & Err.Number & ": " & Err.Description, _
vbCritical
End Sub
Private Sub Form_Load()
bFound = False
nLastPos = 0
CentreForm Me
End Sub
Private Sub Form_Resize()
If WindowState = vbMinimized Then Exit Sub
FormStayOnTop Me, True
End Sub
Private Sub Form_Unload(Cancel As Integer)
FormStayOnTop Me, False
End Sub
Private Sub chkFind_Click(Index As Integer)
If bFound Then
nLastPos = 0
bFound = False
SetCaption cmdFind, "&Find"
End If
End Sub
Private Sub txtFind_Change()
If bFound Then
nLastPos = 0
bFound = False
SetCaption cmdFind, "&Find"
End If
SetEnabled cmdFind, (Not EmptyString(txtFind.Text))
End Sub
Private Sub txtFind_GotFocus()
SelectText txtFind
End Sub
Private Sub txtFind_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Not EmptyString(txtFind.Text) Then
cmdFind_Click
KeyAscii = 0
End If
End If
End Sub