In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Folder Explorer TreeView ....

Xailer English public forum
ChrisGillard
Posts: 384
Joined: Tue May 01, 2007 5:49 pm

Folder Explorer TreeView ....

Postby ChrisGillard » Tue May 30, 2017 1:59 pm

Hi, I am wanting to use a Folder Explorer TreeView to embed in a form .... very similar to the one in Xailer Dbf Explorer.

I am trying to not use a Folder Dialog or an ActiveX.

I have looked at the xailer\samples but cannot see anything similar to use as a start.

Does anyone have a piece of code that might save me doing it totally myself?

Any help would be appreciated.

Chris

Folder TreeView.png
Folder TreeView.png (25.02 KiB) Viewed 1016 times
User avatar
ignacio
Site Admin
Posts: 8509
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

Re: Folder Explorer TreeView ....

Postby ignacio » Wed May 31, 2017 4:49 pm

ChrisGillard wrote:Hi, I am wanting to use a Folder Explorer TreeView to embed in a form .... very similar to the one in Xailer Dbf Explorer.

I am trying to not use a Folder Dialog or an ActiveX.

I have looked at the xailer\samples but cannot see anything similar to use as a start.

Does anyone have a piece of code that might save me doing it totally myself?

Any help would be appreciated.


From the DBF editor:

Code: Select all

METHOD LoadFiles( cDir ) CLASS TFrmMain

   LOCAL oItem
   LOCAL cExt

   IF ::oComboBox1:cText == "ADSADT"
      cExt := "ADT"
   ELSE
      cExt := "DBF"
   ENDIF

   UPDATE ::cDir TO cDir

   Application:lbusy := .t.

   ::oTree:DeleteItems()

   IF !Empty( ::cDir )
      oItem := ::oTree:AddItem( ::cDir, 1, 1, .t. )
      AddTables( oItem, ::cDir, cExt, ::cPerExt )
   ENDIF

   IF ::oTree:GetCount() > 0
      ::oTree:ExpandAll()
      ::oTree:SelectRoot()
   ENDIF

   IF ::oDataSource == NIL
      ::SelectRDD()
   ENDIF

   Application:lbusy := .f.

RETURN NIL

STATIC FUNCTION AddTables( oParent, cDir, cExt, cPerExt )

   LOCAL oItem
   LOCAL aDir, aFile
   LOCAL cFile

   // First we load files

   aDir := Directory( cDir + "\*." + cExt )

   Asort( aDir,,,{|x,y| Upper( x[ 1 ] ) < Upper( y[ 1 ] ) } )

   FOR EACH aFile IN aDir
      cFile := aFile[ F_NAME ]
      WITH OBJECT oParent:AddItem( cFile, 2, 2 )
         :Cargo := cDir + "\" + cFile
      END WITH
   NEXT

   IF !Empty( cPerExt )
      aDir := Directory( cDir + "\*." + cPerExt )
      Asort( aDir,,,{|x,y| Upper( x[ 1 ] ) < Upper( y[ 1 ] ) } )

      FOR EACH aFile IN aDir
         cFile := aFile[ F_NAME ]
         WITH OBJECT oParent:AddItem( cFile, 2, 2 )
            :Cargo := cDir + "\" + cFile
         END WITH
      NEXT
   ENDIF

   // Then we load directories

   aDir := Directory( cDir + "\*.*", "D" )
   Asort( aDir,,,{|x,y| Upper( x[ 1 ] ) < Upper( y[ 1 ] ) } )

   FOR EACH aFile IN aDir
      cFile := aFile[ F_NAME ]
      IF "D" $ aFile[ F_ATTR ] .AND. cFile != "." .AND. cFile != ".."
         WITH OBJECT oParent:AddItem( cFile, 3, 3 )
            AddTables( :__WithObject(), cDir + "\" + cFile, cExt )
         END WITH
      ENDIF
   NEXT

RETURN NIL
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
ChrisGillard
Posts: 384
Joined: Tue May 01, 2007 5:49 pm

Re: Folder Explorer TreeView ....

Postby ChrisGillard » Thu Jun 01, 2017 6:05 pm

Hi Ignacio,

Thank you very much for the code ... it is already looking very nice with some famfamfam icons.
01-06-2017 16-59-24.png
01-06-2017 16-59-24.png (9.99 KiB) Viewed 961 times

Much appreciated.

Chris

Return to “English”