xbrwdisk change directory

xbrwdisk change directory

Postby Otto » Tue Jan 12, 2021 11:30 pm

Dear Mr. Rao,
I try to extend xbrwdisk.prg to change directory with a click on a button.
I use :SetTree.
But then inside xBrowse it adds a new column item.
Can you please help me.

Best regards,
Otto

Code: Select all  Expand view


#include "FiveWin.ch"
#include "xbrowse.ch"
 static aDrives  := {}
//----------------------------------------------------------------------------//

function Main()

   local oDlg, oBrw, oTree, oFont, b
   
    aDrives  := aDrives( 2 )
   
   SET DATE ITALIAN
   SET CENTURY ON

   oTree := MakeTree()

   DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
   DEFINE DIALOG oDlg SIZE 640,440 PIXEL ;
      TITLE 'Directory' ;
      FONT oFont
     
     
       @ 0,0 ;
      BUTTON "Change directory" ;
      ACTION ( aDrives := { "c:\fwh\samples\"}, oTree := MakeTree( aDrives ),  oBrw:SetTree( oTree) );
          OF oDlg

   @ 25,10 XBROWSE oBrw SIZE 300,200 PIXEL OF oDlg NOBORDER

   oBrw:SetTree( oTree, { "
\fwh\bitmaps\open2.bmp", ;
                          "
\fwh\bitmaps\16x16\folder.bmp", ;
                          "
\fwh\bitmaps\16x16\onepage2.bmp" } )
   oBrw:bKeyChar  := { |nKey| If( nKey == VK_RETURN .and. ! Empty( oBrw:oTreeItem:bAction ), ;
                                Eval( oBrw:oTreeItem:bAction, oBrw:oTreeItem ), nil ) }


   WITH OBJECT oBrw:aCols[ 1 ]

      :AddBmpFile( "
\fwh\bitmaps\hdrive.bmp" )
      :nWidth     := 300
      :cHeader    := 'File/Folder'
      b           := :bLDClickData

      :bLDClickData  := { |r,c,f,o| ToggleFolder( r,c,f,o,b ) }

      :bBmpData   := { || If( ':' $ oBrw:oTreeItem:cPrompt, 4, ;
                          If( 'D' $ oBrw:oTreeItem:Cargo[ 5 ], ;
                          If( oBrw:oTreeItem:lOpened, 1, 2 ), 3 ) ) }

   END

   ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 2 ] ;
         PICTURE '@EZ 999,999,999' HEADER 'Bytes'
   ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 3 ] HEADER 'Date'
   ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 4 ] HEADER 'Time'
   ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 5 ] HEADER 'Attr'

   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTER

return nil

//----------------------------------------------------------------------------//

static function ToggleFolder( r, c, f, oCol, b )

   local oBrw  := oCol:oBrw
   local oItem := oBrw:oTreeItem

   If ! oItem:lOpened .and. ! Empty( oItem:bAction )
      Eval( oItem:bAction, oItem )
   endif

   if b != nil
      Eval( b, r, c, f, oCol )
   endif

return nil

//----------------------------------------------------------------------------//

static function MakeTree()

   local oTree, oItem, n
 

   TREE oTree

   for n := 1 to Len( aDrives )

      TREEITEM oItem PROMPT aDrives[ n ]
      oItem:Cargo    := { aDrives[ n ], 0, CtoD( '' ), Space( 8 ), 'D', ;
                        aDrives[ n ] }

      oItem:bAction  := { |o| o:SetTree( SubTree( o ) ), o:bACtion := nil }

   next

   ENDTREE

return oTree

//----------------------------------------------------------------------------//

static function SubTree( oParent )

   local oTree, n, oItem, nLevel, nItems := 0
   local cFolder := oParent:Cargo[ 6 ]
   local aDir     := Directory( cFolder + '\*.*', 'D' )

   nLevel   := oParent:nLevel + 1

   TREE oTree
   for n := 1 to Len( aDir )
      if ! ( aDir[ n ][ 1 ] = '.' )

         TREEITEM oItem PROMPT aDir[ n ][ 1 ]

         oItem:nlevel := nLevel
         oItem:Cargo  := aDir[ n ]

         AAdd( oItem:Cargo, cFolder + Chr(92) + aDir[ n ][ 1 ] )

         if 'D' $ aDir[ n ][ 5 ]
            oItem:bAction  := { |o| o:SetTree( SubTree( o ) ), o:bACtion := nil }
         else
            oItem:bAction  := { |o| MsgInfo( o:cPrompt ) }
         endif
         nItems++
      endif
   next
   if nItems == 0
      n--
      TREEITEM oItem PROMPT ''
      oItem:nlevel := nLevel
      aDir[ n ][ 5 ] := 'A'
      oItem:Cargo  := { '', 0, CToD( '' ), Space(8), ' ', '' }
      AAdd( oItem:Cargo, cFolder + Chr(92) + aDir[ n ][ 1 ] )
   endif
   ENDTREE

return oTree

//----------------------------------------------------------------------------//




********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6330
Joined: Fri Oct 07, 2005 7:07 pm

Re: xbrwdisk change directory

Postby nageswaragunupudi » Wed Jan 13, 2021 5:21 am

Sure, please wait.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10629
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrwdisk change directory

Postby nageswaragunupudi » Wed Jan 13, 2021 9:06 pm

Code: Select all  Expand view
     @ 0,0 ;
      BUTTON "Change directory" ;
      ACTION ( aDrives := { "c:\fwh\samples"}, oTree := MakeTree( aDrives ),  ;
            oBrw:oTree := oTree, oBrw:GoTop(),oBrw:Refresh() );
          OF oDlg
 


and also change :bBmpData as below:
Code: Select all  Expand view
     :bBmpData   := { || If( Right( oBrw:oTreeItem:cPrompt, 1 ) == ":", 4, ;
                          If( 'D' $ oBrw:oTreeItem:Cargo[ 5 ], ;
                          If( oBrw:oTreeItem:lOpened, 1, 2 ), 3 ) ) }
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10629
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrwdisk change directory

Postby Otto » Wed Jan 13, 2021 10:21 pm

Dear Mr. Rao,
Many Thanks. I made the changes, and everything worked.

Is there any way that you can seek in the tree?

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6330
Joined: Fri Oct 07, 2005 7:07 pm

Re: xbrwdisk change directory

Postby Otto » Wed Jan 13, 2021 11:19 pm

Dear Mr. Rao,
I tried to have the tree open at the directory change to use ToggleFolder.
This works. But is this the way how to do it.

Code: Select all  Expand view


@ 0,0 ;
      BUTTON "Change directory" ;
      ACTION ( aDrives := { "c:\fwh\samples"}, oTree := MakeTree( aDrives ),  ;
            oBrw:oTree := oTree, oBrw:GoTop(),oBrw:Refresh(), ToggleFolder( 25,25,1,oBrw:aCols[ 1 ],oBrw:aCols[ 1 ]:bLDClickData ) );
          OF oDlg


Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6330
Joined: Fri Oct 07, 2005 7:07 pm

Re: xbrwdisk change directory

Postby nageswaragunupudi » Thu Jan 14, 2021 1:05 pm

Otto wrote:Dear Mr. Rao,
I tried to have the tree open at the directory change to use ToggleFolder.
This works. But is this the way how to do it.

Code: Select all  Expand view


@ 0,0 ;
      BUTTON "Change directory" ;
      ACTION ( aDrives := { "c:\fwh\samples"}, oTree := MakeTree( aDrives ),  ;
            oBrw:oTree := oTree, oBrw:GoTop(),oBrw:Refresh(), ToggleFolder( 25,25,1,oBrw:aCols[ 1 ],oBrw:aCols[ 1 ]:bLDClickData ) );
          OF oDlg


Best regards,
Otto


Instead, change MakeTree() like this
Code: Select all  Expand view
static function MakeTree()

   local oTree, oItem, n


   TREE oTree

   for n := 1 to Len( aDrives )

      TREEITEM oItem PROMPT aDrives[ n ]
      oItem:Cargo    := { aDrives[ n ], 0, CtoD( '' ), Space( 8 ), 'D', ;
                        aDrives[ n ] }

      if Len( aDrives ) == 1
         oItem:SetTree( SubTree( oItem ) )
         oItem:Open()
      else
         oItem:bAction  := { |o| o:SetTree( SubTree( o ) ), o:bACtion := nil }
      endif

   next

   ENDTREE

return oTree
 


This is a very old program.
I am considering revising it.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10629
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrwdisk change directory

Postby Otto » Sat Jan 16, 2021 9:06 am

Dear Mr. Rao,
Thank you for your help.
Now Harbourino Manager is ready.
Do you think you will provide "Search" for treeview shortly?
Have a lovely weekend and best regards,
Otto

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6330
Joined: Fri Oct 07, 2005 7:07 pm

Re: xbrwdisk change directory

Postby nageswaragunupudi » Sat Jan 16, 2021 7:20 pm

Do you think you will provide "Search" for treeview shortly?


Yes, please.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10629
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrwdisk change directory

Postby Otto » Sun Jan 17, 2021 10:13 pm

Dear Mr. Rao,
Thank you. In the meantime I use a workaround and have finished Harbourino Manager.

This video shows the Harbourino Manager. All functions can be carried out from one console.

https://mybergland.com/fwforum/harbourinomanager.mp4

If anyone would like to install and try Harbourino, please just write me. Then I can give you a download link.

Best regards,
Otto

Code: Select all  Expand view

static function SubTree( oParent )

   local oTree, n, oItem, nLevel, nItems := 0
   local cFolder := oParent:Cargo[ 6 ]
   local aDir     := Directory( cFolder + '\*.*', 'D' )

   nLevel   := oParent:nLevel + 1

   TREE oTree
   for n := 1 to Len( aDir )
      if ! ( aDir[ n ][ 1 ] = '.' )
if UPPER(aDir[ n ][ 1 ]) >= UPPER( ALLTRIM( cSearch ) )
         TREEITEM oItem PROMPT aDir[ n ][ 1 ]

         oItem:nlevel := nLevel
         oItem:Cargo  := aDir[ n ]

         AAdd( oItem:Cargo, cFolder + Chr(92) + aDir[ n ][ 1 ] )

         if 'D' $ aDir[ n ][ 5 ]
            oItem:bAction  := { |o| o:SetTree( SubTree( o ) ), o:bACtion := nil }
         else
            oItem:bAction  := { |o| MsgInfo( o:cPrompt ) }
         endif
         nItems++
      endif
 endif      
   next
   if nItems == 0
      n--
      TREEITEM oItem PROMPT ''
      oItem:nlevel := nLevel
      aDir[ n ][ 5 ] := 'A'
      oItem:Cargo  := { '', 0, CToD( '' ), Space(8), ' ', '' }
      AAdd( oItem:Cargo, cFolder + Chr(92) + aDir[ n ][ 1 ] )
   endif
   ENDTREE
cSearch := "                      "

return oTree

//----------------------------------------------------------------------------//


 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6330
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi and 87 guests