Content Supported by Sourcelens Consulting
VERSION 5.00
Begin VB.Form WinSeek
BackColor = &H00C0C0C0&
BorderStyle = 3
Caption = "WinSeek"
ClientHeight = 4020
ClientLeft = 1920
ClientTop = 1890
ClientWidth = 3720
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 1
Weight = 700
Underline = 0
Italic = 0
Strikethrough = 0
EndProperty
ForeColor = &H00000080&
Height = 4395
Left = 1875
MaxButton = 0
MinButton = 0
ScaleHeight = 4020
ScaleWidth = 3720
Top = 1560
Width = 3810
Begin VB.PictureBox Picture2
BorderStyle = 0
Height = 2895
Left = 720
ScaleHeight = 2895
ScaleWidth = 3855
TabIndex = 8
Top = 1080
Visible = 0
Width = 3855
Begin VB.ListBox lstFoundFiles
Height = 2235
Left = 120
TabIndex = 11
Top = 480
Width = 3375
End
Begin VB.Label lblCount
Caption = "0"
Height = 255
Left = 1200
TabIndex = 10
Top = 120
Width = 1095
End
Begin VB.Label lblfound
Caption = "&Files Found:"
Height = 255
Left = 120
TabIndex = 9
Top = 120
Width = 1095
End
End
Begin VB.PictureBox Picture1
BorderStyle = 0
Height = 2895
Left = 0
ScaleHeight = 2895
ScaleWidth = 3735
TabIndex = 2
Top = 120
Width = 3735
Begin VB.DriveListBox drvList
Height = 1530
Left = 2040
TabIndex = 7
Top = 480
Width = 1575
End
Begin VB.DirListBox dirList
Height = 1695
Left = 2040
TabIndex = 6
Top = 960
Width = 1575
End
Begin VB.FileListBox filList
Height = 2040
Left = 120
TabIndex = 5
Top = 480
Width = 1815
End
Begin VB.TextBox txtSearchSpec
Height = 285
Left = 2040
TabIndex = 4
Text = "*.*"
Top = 120
Width = 1575
End
Begin VB.Label lblCriteria
Caption = "Search &Criteria:"
Height = 255
Left = 600
TabIndex = 3
Top = 120
Width = 1335
End
End
Begin VB.CommandButton cmdSearch
BackColor = &H00C0C0C0&
Caption = "&Search"
Default = -1
Height = 720
Left = 480
TabIndex = 0
Top = 3000
Width = 1200
End
Begin VB.CommandButton cmdExit
BackColor = &H00C0C0C0&
Caption = "E&xit"
Height = 720
Left = 2040
TabIndex = 1
Top = 3000
Width = 1200
End
End
Option Explicit
Dim SearchFlag As Integer
Private Sub cmdExit_Click()
If cmdExit.Caption = "E&xit" Then
End
Else
SearchFlag = False
End If
End Sub
Private Sub cmdSearch_Click()
Dim FirstPath As String, DirCount As Integer, NumFiles As Integer
Dim result As Integer
If cmdSearch.Caption = "&Reset" Then
ResetSearch
txtSearchSpec.SetFocus
Exit Sub
End If
If dirList.Path <> dirList.List(dirList.ListIndex) Then
dirList.Path = dirList.List(dirList.ListIndex)
Exit Sub
End If
Picture2.Move 0, 0
Picture1.Visible = False
Picture2.Visible = True
cmdExit.Caption = "Cancel"
filList.Pattern = txtSearchSpec.Text
FirstPath = dirList.Path
DirCount = dirList.ListCount
NumFiles = 0
result = DirDiver(FirstPath, DirCount, "")
filList.Path = dirList.Path
cmdSearch.Caption = "&Reset"
cmdSearch.SetFocus
cmdExit.Caption = "E&xit"
End Sub
Private Function DirDiver(NewPath As String, DirCount As Integer, BackUp As String) As Integer
Static FirstErr As Integer
Dim DirsToPeek As Integer, AbandonSearch As Integer, ind As Integer
Dim OldPath As String, ThePath As String, entry As String
Dim retval As Integer
SearchFlag = True
DirDiver = False
retval = DoEvents()
If SearchFlag = False Then
DirDiver = True
Exit Function
End If
On Local Error GoTo DirDriverHandler
DirsToPeek = dirList.ListCount
Do While DirsToPeek > 0 And SearchFlag = True
OldPath = dirList.Path
dirList.Path = NewPath
If dirList.ListCount > 0 Then
dirList.Path = dirList.List(DirsToPeek - 1)
AbandonSearch = DirDiver((dirList.Path), DirCount%, OldPath)
End If
DirsToPeek = DirsToPeek - 1
If AbandonSearch = True Then Exit Function
Loop
If filList.ListCount Then
If Len(dirList.Path) <= 3 Then
ThePath = dirList.Path
Else
ThePath = dirList.Path + "\"
End If
For ind = 0 To filList.ListCount - 1
entry = ThePath + filList.List(ind)
lstFoundFiles.AddItem entry
lblCount.Caption = Str(Val(lblCount.Caption) + 1)
Next ind
End If
If BackUp <> "" Then
dirList.Path = BackUp
End If
Exit Function
DirDriverHandler:
If Err = 7 Then
DirDiver = True
MsgBox "You've filled the list box. Abandoning search..."
Exit Function
Else
MsgBox Error
End
End If
End Function
Private Sub DirList_Change()
filList.Path = dirList.Path
End Sub
Private Sub DirList_LostFocus()
dirList.Path = dirList.List(dirList.ListIndex)
End Sub
Private Sub DrvList_Change()
On Error GoTo DriveHandler
dirList.Path = drvList.Drive
Exit Sub
DriveHandler:
drvList.Drive = dirList.Path
Exit Sub
End Sub
Private Sub Form_Load()
Picture2.Move 0, 0
Picture2.Width = WinSeek.ScaleWidth
Picture2.BackColor = WinSeek.BackColor
lblCount.BackColor = WinSeek.BackColor
lblCriteria.BackColor = WinSeek.BackColor
lblfound.BackColor = WinSeek.BackColor
Picture1.Move 0, 0
Picture1.Width = WinSeek.ScaleWidth
Picture1.BackColor = WinSeek.BackColor
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub ResetSearch()
lstFoundFiles.Clear
lblCount.Caption = 0
SearchFlag = False
Picture2.Visible = False
cmdSearch.Caption = "&Search"
cmdExit.Caption = "E&xit"
Picture1.Visible = True
dirList.Path = CurDir: drvList.Drive = dirList.Path
End Sub
Private Sub txtSearchSpec_Change()
filList.Pattern = txtSearchSpec.Text
End Sub
Private Sub txtSearchSpec_GotFocus()
txtSearchSpec.SelStart = 0
txtSearchSpec.SelLength = Len(txtSearchSpec.Text)
End Sub