Folder Viewport

Folder Viewport

Postby Natter » Thu Oct 26, 2023 11:01 am

Hi,

There are several disks on the computer - C:\,D:\, E:\..
I need to select a folder from disk c D:\ (c getDir() or cGetDir32()).
Is it possible to make only the D:\ drive available ?
Natter
 
Posts: 1195
Joined: Mon May 14, 2007 9:49 am

Re: Folder Viewport

Postby Antonio Linares » Thu Oct 26, 2023 11:04 am

You could build and show a tree using only the folders in such drive
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42048
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Folder Viewport

Postby Natter » Thu Oct 26, 2023 11:09 am

Sorry, Antonio, I didn't understand. I can specify the initial path, but the rest of the disks will also be visible and can be selected
Natter
 
Posts: 1195
Joined: Mon May 14, 2007 9:49 am

Re: Folder Viewport

Postby Antonio Linares » Thu Oct 26, 2023 11:57 am

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

    local oDlg, oTree

    DEFINE DIALOG oDlg TITLE "Select a folder" SIZE 600, 400

    @ 10, 10 TREEVIEW oTree OF oDlg SIZE 200, 180 PIXEL

    @ 0.5, 40 BUTTON "OK" OF oDlg ACTION MsgInfo( oTree:GetSelected():cPrompt ) SIZE 50, 15
 
    ACTIVATE DIALOG oDlg CENTER ;
      ON INIT ( oDlg:Show(), GetFolders( "c:", oTree ), .T. )

return nil    

function GetFolders( cPath, oItem )

   local aFolders := Directory( cPath + "\*.*", "D" )

   AEval( aFolders, { | aFolder, oNewItem | If( aFolder[ 5 ] == "D" .and. aFolder[ 1 ] != "." .and. aFolder[ 1 ] != "..",;
                      ( oNewItem := oItem:Add( Upper( aFolder[ 1 ] ) ), GetFolders( cPath + "\" + aFolder[ 1 ], oNewItem ) ),) } )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42048
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Folder Viewport

Postby Natter » Thu Oct 26, 2023 12:14 pm

That is, make your own version of the cGetDir() function? Thank you, Antonio! I'll try
Natter
 
Posts: 1195
Joined: Mon May 14, 2007 9:49 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 17 guests