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
Responder
ChrisGillard
Mensajes: 384
Registrado: Mar May 01, 2007 5:49 pm

Folder Explorer TreeView ....

Mensaje por ChrisGillard »

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) Visto 3034 veces
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9252
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: Folder Explorer TreeView ....

Mensaje por ignacio »

ChrisGillard escribió: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:

Código: Seleccionar todo

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]
https://www.xailer.com
ChrisGillard
Mensajes: 384
Registrado: Mar May 01, 2007 5:49 pm

Re: Folder Explorer TreeView ....

Mensaje por ChrisGillard »

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) Visto 2979 veces
Much appreciated.

Chris
Responder