Hi Everyone, in advance thanks a lot,
I have this code below, well as you know it creates a form,a grid and textoxes, i just want after i pressed the Escape key to stop the processing search in a case that i want to interrupt the searching or stop it, this i can do itno problem is part of the Filer, then after that i want to clear the textboxes values as well the grid data displayed, i already created a command to clear the textboxes and the grid vales but the grid does not clear the displayed data(most likely cause i am not doing it right), please find the line that says "this proced allow me to clear the values on txtboxes and the Grid" there is the proced for that cmdbutton also if you can tell me why the Scrollbar horizontal does not work ?, it is always dimmed, and believe me when data is displayed in the grid, i need to scroll horizontally but it is still dimmed and can not do it.
here is the code in my prg file, you can copy it and run it if you need to test it.
_screen.caption=" Find a File... "
SET SAFETY OFF
Local oForm As Form
oForm = Createobject('Form1')
oForm.Show(1)
Return
Define Class Form1 As Form
Height = 470
AutoCenter = .T.
Caption = "Search Tool..., To Stop Or cancel Press Escape Key "
Width = 655
Add Object label1 As Label With ;
top = 30, Left = 10, Caption = 'Search File', AutoSize = .T.
Add Object txtFile As TextBox With ;
top = 28, Left = 100, Value = '', Width = 200
Add Object label4 As Label With ;
top = 30, Left = 302, Caption = 'Type the Filename and the Extension as(ie.. 12356.dwg', AutoSize = .T.
Add Object label2 As Label With;
Top = 60, Left = 10, Caption = 'Target Folder', AutoSize = .T.
Add Object label3 As Label With;
Top = 85, Left = 140, Caption = 'Input Target Folder Mapped drive Letters as(ie.. O:\;P:\Q:\)' ,AutoSize = .T.
Add Object txtFolder As TextBox With ;
top = 58, Left = 100, Value = '', Width = 400
Add Object cmdFolder As CommandButton With;
top = 56, Left = 505, Caption = '...', Width = 20, Height = 24
Add Object cmdSearch As CommandButton With;
top = 85, Left = 10, Caption = 'Start \<Searching', Width = 120, Height = 24
Add Object chkSub As Checkbox With;
top = 85, Left = 464, Caption = 'Include Sub Folders', Value = 1, AutoSize = .T.
Add Object grid1 As Grid With ;
Top = 120, Left = 10, Height = 300, Width = 600, ColumnCount = 1,;
ForeColor = RGB(0,255,0), deletemark = .F., AllowCellSelection = .F., GridLines = 0, ;
HeaderHeight = 0, RecordMark = .F., ScrollBars = 3
**Width = 600 WAS 550
*
*Add Object grid1 As Grid With ;
Top = 120, Left = 10, Height = 300, Width = 550, ColumnCount = 1,;
deletemark = .F., AllowCellSelection = .F., GridLines = 0, ;
HeaderHeight = 0, RecordMark = .F., ScrollBars = 3
Add Object cmdOpen As CommandButton With;
top = 425, Left = 10, Caption = 'O\<pen File', Width = 120, Height = 24
Add Object cmdExplore As CommandButton With;
top = 425, Left = 150, Caption = 'E\<xplore', Width = 120, Height = 24
Add Object cmdQuit As CommandButton With;
top = 425, Left = 300, Caption = 'Q\<uit', Width = 120, Height = 24
Add Object cmdClearS As CommandButton With;
top = 425, Left = 450, Caption = 'C\<learScreen', Width = 120, Height = 24
Procedure Load
Create Cursor junk (filename Varchar(250))
Declare Integer ShellExecute In shell32.Dll ;
INTEGER hndWin, String cAction, String cFileName, ;
STRING cParams, String cDir, Integer nShowWin
Endproc
** THIS PROCEDURE ALLOW ONLY ONE DRIVE TO BE SEARCHED
*Procedure cmdFolder.Click
* Thisform.txtFolder.Value = Getdir()
*Endproc
** **THIS PROCEDURE BELOW ALLOW MULTIPLEe DRIVES TO BE SEARCHED
Procedure cmdFolder.Click
LOCAL lcFolder, lcFolders
lcFolder = GETDIR()
lcFolders = ALLTRIM(thisform.txtFolder.Value)
lcFolders = IIF(EMPTY(m.lcFolders),'',m.lcFolders+';')+m.lcFolder
* Remove extra ; just in case it was keyed-in as well
Thisform.txtFolder.Value = STRTRAN(m.lcFolders,';;',';')
ENDPROC
Procedure grid1.Init
This.RecordSourceType = 1
This.RecordSource = 'junk'
This.Column1.Width = 530
Endproc
Procedure cmdOpen.Click
ShellExecute(0,"open",Alltrim(junk.filename),"","",1)
Endproc
Procedure cmdExplore.Click
ShellExecute(0,"open",'explorer.exe',Justpath(Alltrim(junk.filename)),"",1)
ENDPROC
Procedure cmdQuit.Click
USE
WAIT clear
Thisform.Refresh
thisform.Release
ENDPROC
** this proced allow me to clear the values on txtboxes and the Grid
PROCEDURE cmdClearS.Click
WAIT clear
thisform.txtFile.Value = ''
THISFORM.txtFolder.Value = ''
THISFORM.GRID1.SETFOCUS
thisform.grid1.Value = 0
thisform.grid1.refresh
Thisform.Refresh
ENDPROC
Procedure cmdSearch.Click
Local lcFile, lcFolder
lcFile = Alltrim(Thisform.txtFile.Value)
* Validate file
If Empty(m.lcFile)
Messagebox('Please type the file to be searched first!',0+64,'Oppppppssss!')
Thisform.txtFile.SetFocus
Return(.F.)
Endif
lcFolder = Alltrim(Thisform.txtFolder.Value)
* Validate folder
If Empty(m.lcFolder)
Messagebox('Please Select the folder to be searched first!',0+64,'Oppppppssss!')
Thisform.txtFolder.SetFocus
Return(.F.)
Endif
**** Here is the loop, GetWordCount() and GetWordNum()
lnPaths = Getwordcount(m.lcFolder,';')
Zap In junk
For lnCtr = 1 To m.lnPaths
lcPath = Getwordnum(m.lcFolder,m.lnCtr,';')
Wait Window 'Working on '+m.lcPath+'......' NOWAIT &&NOCLEAR
Thisform.SearchMe(m.lcPath, m.lcFile)
Next
Wait Clear
Go Top
** new by ep
if empty(junk.filename)
Messagebox('File does not exist on any drive..',0+64,'Oppppppssss!')
endif
** end new by ep
Thisform.grid1.Refresh
Endproc
Procedure SearchMe
Lparameters lcPath, lcFile
* start Searching
Local loFiler As Filer.fileutil, lnloop, lnCtr, lcPath, lnPaths
loFiler = Createobject('filer.fileutil')
With loFiler
.SearchPath = m.lcPath
.Subfolder = Thisform.chkSub.Value
.FileExpression = m.lcFile
.Find(0)
For lnloop=1 To .Files.Count
lcFile = Addbs(.Files(m.lnloop).Path)+.Files(m.lnloop).Name
Insert Into junk Values (m.lcFile)
Endfor
Endwith
loFiler = .Null.
Endproc
Enddefine
I have this code below, well as you know it creates a form,a grid and textoxes, i just want after i pressed the Escape key to stop the processing search in a case that i want to interrupt the searching or stop it, this i can do itno problem is part of the Filer, then after that i want to clear the textboxes values as well the grid data displayed, i already created a command to clear the textboxes and the grid vales but the grid does not clear the displayed data(most likely cause i am not doing it right), please find the line that says "this proced allow me to clear the values on txtboxes and the Grid" there is the proced for that cmdbutton also if you can tell me why the Scrollbar horizontal does not work ?, it is always dimmed, and believe me when data is displayed in the grid, i need to scroll horizontally but it is still dimmed and can not do it.
here is the code in my prg file, you can copy it and run it if you need to test it.
_screen.caption=" Find a File... "
SET SAFETY OFF
Local oForm As Form
oForm = Createobject('Form1')
oForm.Show(1)
Return
Define Class Form1 As Form
Height = 470
AutoCenter = .T.
Caption = "Search Tool..., To Stop Or cancel Press Escape Key "
Width = 655
Add Object label1 As Label With ;
top = 30, Left = 10, Caption = 'Search File', AutoSize = .T.
Add Object txtFile As TextBox With ;
top = 28, Left = 100, Value = '', Width = 200
Add Object label4 As Label With ;
top = 30, Left = 302, Caption = 'Type the Filename and the Extension as(ie.. 12356.dwg', AutoSize = .T.
Add Object label2 As Label With;
Top = 60, Left = 10, Caption = 'Target Folder', AutoSize = .T.
Add Object label3 As Label With;
Top = 85, Left = 140, Caption = 'Input Target Folder Mapped drive Letters as(ie.. O:\;P:\Q:\)' ,AutoSize = .T.
Add Object txtFolder As TextBox With ;
top = 58, Left = 100, Value = '', Width = 400
Add Object cmdFolder As CommandButton With;
top = 56, Left = 505, Caption = '...', Width = 20, Height = 24
Add Object cmdSearch As CommandButton With;
top = 85, Left = 10, Caption = 'Start \<Searching', Width = 120, Height = 24
Add Object chkSub As Checkbox With;
top = 85, Left = 464, Caption = 'Include Sub Folders', Value = 1, AutoSize = .T.
Add Object grid1 As Grid With ;
Top = 120, Left = 10, Height = 300, Width = 600, ColumnCount = 1,;
ForeColor = RGB(0,255,0), deletemark = .F., AllowCellSelection = .F., GridLines = 0, ;
HeaderHeight = 0, RecordMark = .F., ScrollBars = 3
**Width = 600 WAS 550
*
*Add Object grid1 As Grid With ;
Top = 120, Left = 10, Height = 300, Width = 550, ColumnCount = 1,;
deletemark = .F., AllowCellSelection = .F., GridLines = 0, ;
HeaderHeight = 0, RecordMark = .F., ScrollBars = 3
Add Object cmdOpen As CommandButton With;
top = 425, Left = 10, Caption = 'O\<pen File', Width = 120, Height = 24
Add Object cmdExplore As CommandButton With;
top = 425, Left = 150, Caption = 'E\<xplore', Width = 120, Height = 24
Add Object cmdQuit As CommandButton With;
top = 425, Left = 300, Caption = 'Q\<uit', Width = 120, Height = 24
Add Object cmdClearS As CommandButton With;
top = 425, Left = 450, Caption = 'C\<learScreen', Width = 120, Height = 24
Procedure Load
Create Cursor junk (filename Varchar(250))
Declare Integer ShellExecute In shell32.Dll ;
INTEGER hndWin, String cAction, String cFileName, ;
STRING cParams, String cDir, Integer nShowWin
Endproc
** THIS PROCEDURE ALLOW ONLY ONE DRIVE TO BE SEARCHED
*Procedure cmdFolder.Click
* Thisform.txtFolder.Value = Getdir()
*Endproc
** **THIS PROCEDURE BELOW ALLOW MULTIPLEe DRIVES TO BE SEARCHED
Procedure cmdFolder.Click
LOCAL lcFolder, lcFolders
lcFolder = GETDIR()
lcFolders = ALLTRIM(thisform.txtFolder.Value)
lcFolders = IIF(EMPTY(m.lcFolders),'',m.lcFolders+';')+m.lcFolder
* Remove extra ; just in case it was keyed-in as well
Thisform.txtFolder.Value = STRTRAN(m.lcFolders,';;',';')
ENDPROC
Procedure grid1.Init
This.RecordSourceType = 1
This.RecordSource = 'junk'
This.Column1.Width = 530
Endproc
Procedure cmdOpen.Click
ShellExecute(0,"open",Alltrim(junk.filename),"","",1)
Endproc
Procedure cmdExplore.Click
ShellExecute(0,"open",'explorer.exe',Justpath(Alltrim(junk.filename)),"",1)
ENDPROC
Procedure cmdQuit.Click
USE
WAIT clear
Thisform.Refresh
thisform.Release
ENDPROC
** this proced allow me to clear the values on txtboxes and the Grid
PROCEDURE cmdClearS.Click
WAIT clear
thisform.txtFile.Value = ''
THISFORM.txtFolder.Value = ''
THISFORM.GRID1.SETFOCUS
thisform.grid1.Value = 0
thisform.grid1.refresh
Thisform.Refresh
ENDPROC
Procedure cmdSearch.Click
Local lcFile, lcFolder
lcFile = Alltrim(Thisform.txtFile.Value)
* Validate file
If Empty(m.lcFile)
Messagebox('Please type the file to be searched first!',0+64,'Oppppppssss!')
Thisform.txtFile.SetFocus
Return(.F.)
Endif
lcFolder = Alltrim(Thisform.txtFolder.Value)
* Validate folder
If Empty(m.lcFolder)
Messagebox('Please Select the folder to be searched first!',0+64,'Oppppppssss!')
Thisform.txtFolder.SetFocus
Return(.F.)
Endif
**** Here is the loop, GetWordCount() and GetWordNum()
lnPaths = Getwordcount(m.lcFolder,';')
Zap In junk
For lnCtr = 1 To m.lnPaths
lcPath = Getwordnum(m.lcFolder,m.lnCtr,';')
Wait Window 'Working on '+m.lcPath+'......' NOWAIT &&NOCLEAR
Thisform.SearchMe(m.lcPath, m.lcFile)
Next
Wait Clear
Go Top
** new by ep
if empty(junk.filename)
Messagebox('File does not exist on any drive..',0+64,'Oppppppssss!')
endif
** end new by ep
Thisform.grid1.Refresh
Endproc
Procedure SearchMe
Lparameters lcPath, lcFile
* start Searching
Local loFiler As Filer.fileutil, lnloop, lnCtr, lcPath, lnPaths
loFiler = Createobject('filer.fileutil')
With loFiler
.SearchPath = m.lcPath
.Subfolder = Thisform.chkSub.Value
.FileExpression = m.lcFile
.Find(0)
For lnloop=1 To .Files.Count
lcFile = Addbs(.Files(m.lnloop).Path)+.Files(m.lnloop).Name
Insert Into junk Values (m.lcFile)
Endfor
Endwith
loFiler = .Null.
Endproc
Enddefine