home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmFindFile
- BorderStyle = 1 'Fixed Single
- Caption = "Find File..."
- ClientHeight = 3360
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 5880
- Icon = "frmFindFile.frx":0000
- LinkTopic = "frmFindFile"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 3360
- ScaleWidth = 5880
- StartUpPosition = 3 'Windows Default
- Begin VB.ComboBox cmbString
- Height = 315
- Left = 120
- TabIndex = 5
- Top = 220
- Width = 2655
- End
- Begin VB.CommandButton cmdCancel
- Cancel = -1 'True
- Caption = "&Cancel"
- Height = 375
- Left = 4560
- TabIndex = 4
- Top = 180
- Width = 1095
- End
- Begin VB.CommandButton cmdFind
- Caption = "&Find File"
- Default = -1 'True
- Height = 375
- Left = 2880
- TabIndex = 0
- Top = 180
- Width = 1095
- End
- Begin VB.DirListBox Dir1
- Height = 2115
- Left = 120
- TabIndex = 2
- Top = 1080
- Width = 2655
- End
- Begin VB.DriveListBox Drive1
- Height = 315
- Left = 120
- TabIndex = 1
- Top = 720
- Width = 2655
- End
- Begin VB.FileListBox File1
- Height = 2430
- Left = 2880
- TabIndex = 3
- Top = 720
- Width = 2895
- End
- Attribute VB_Name = "frmFindFile"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- ' FindFile by Amir Malik
- ' website: http://amir142.cjb.net
- ' e-mail : amir@infoteen.com
- Option Explicit
- Private mbIgnoreListClick As Boolean
- Private Sub cmbString_Click()
- If Not mbIgnoreListClick Then
- 'Click code goes here
- End If
- End Sub
- Private Sub cmbString_KeyPress(KeyAscii As Integer)
- Dim sSearchText As String
- Dim lReturn As Long
-
- If KeyAscii = 13 Then
- cmbString_Click
- KeyAscii = 0
- Else
- sSearchText = Left$(cmbString.Text, cmbString.SelStart) & Chr$(KeyAscii)
- lReturn = SendMessage(cmbString.hWnd, CB_FINDSTRING, -1, ByVal sSearchText)
- If lReturn <> CB_ERR Then
- mbIgnoreListClick = True
- cmbString.ListIndex = lReturn
- mbIgnoreListClick = False
- cmbString.Text = cmbString.List(lReturn)
- cmbString.SelStart = Len(sSearchText)
- cmbString.SelLength = Len(cmbString.Text)
- KeyAscii = 0
- End If
- End If
- End Sub
- Private Sub cmdCancel_Click()
- End
- End Sub
- Private Sub cmdFind_Click()
- ReDim sArray(0) As String
- Call DirWalk(cmbString, Dir1.Path, sArray)
- cmbString.AddItem cmbString
- End Sub
- Sub DirWalk(ByVal sPattern As String, ByVal CurrDir As String, sFound() As String)
- Dim i As Integer
- Dim sCurrPath As String
- Dim sFile As String
- Dim ii As Integer
- Dim iFiles As Integer
- Dim iLen As Integer
- If Right$(CurrDir, 1) <> "\" Then
- Dir1.Path = CurrDir & "\"
- Dir1.Path = CurrDir
- End If
- For i = 0 To Dir1.ListCount
- If Dir1.List(i) <> "" Then
- DoEvents
- Call DirWalk(sPattern, Dir1.List(i), sFound)
- Else
- If Right$(Dir1.Path, 1) = "\" Then
- sCurrPath = Left(Dir1.Path, Len(Dir1.Path) - 1)
- Else
- sCurrPath = Dir1.Path
- End If
- File1.Path = sCurrPath
- File1.Pattern = sPattern
- If File1.ListCount > 0 Then 'matching files found in the directory
- For ii = 0 To File1.ListCount - 1
- ReDim Preserve sFound(UBound(sFound) + 1)
- sFound(UBound(sFound) - 1) = sCurrPath & "\" & File1.List(ii)
- Next ii
- End If
- iLen = Len(Dir1.Path)
- Do While Mid(Dir1.Path, iLen, 1) <> "\"
- iLen = iLen - 1
- Loop
- Dir1.Path = Mid(Dir1.Path, 1, iLen)
- End If
- Next i
- End Sub
- Private Sub Dir1_Change()
- File1.Path = Dir1.Path
- End Sub
- Private Sub Drive1_Change()
- Dir1.Path = Drive1.Drive
- End Sub
- Private Sub Form_Load()
- Dim lne$, file
- file = App.Path & "\recent.txt"
- Open file For Input As #1
- Do While Not EOF(1)
- Line Input #1, lne$
- cmbString.AddItem lne$
- Loop
- Close #1
- End Sub
-