Possible with <cGetDir> select from a opend Main-Dir ?

Possible with <cGetDir> select from a opend Main-Dir ?

Postby ukoenig » Wed Aug 01, 2012 12:23 pm

Hello,

is it possible to show the Sub-Directorys from inside a opend Main-Directory ?
I tested, it only shows the Main-directory ( doesn't open ) :

cDirName := cGetDir( "Select a directory", "D:\P_xbrwimg_plan\" )

Image

D:\P_xbrwimg_plan <- Selection from here with visible Subdirectorys
---- Subdir1
---- Subdir2

Best Regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Possible with <cGetDir> select from a opend Main-Dir ?

Postby Enrico Maria Giordano » Wed Aug 01, 2012 1:48 pm

Did you try to click on the small white triangle?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Re: Possible with <cGetDir> select from a opend Main-Dir ?

Postby ukoenig » Wed Aug 01, 2012 1:52 pm

Enrico,

Open with Dbl-Click is OK no Problem, but I want to jump straight inside the Main-directory.
I don't want, the User can open a wrong Main-Directory by mistake.

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Re: Possible with <cGetDir> select from a opend Main-Dir ?

Postby ukoenig » Wed Aug 01, 2012 2:18 pm

Enrico,

I think the only Solution will be,
using the DIRECTORY-function and display the Sub-directorys inside a small Listbox for Selection.

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Possible with <cGetDir> select from a opend Main-Dir ?

Postby ukoenig » Wed Aug 01, 2012 6:13 pm

Enrico,

this comes very close to the Solution I'm looking for :
with the Project-button selecting a Subdirectory.
I can switch at Runtime between different created Projects.

It is not completed : I still need a Return-value of the clicked Subdir
and maybe opening the tree. ( I had to click on the Main-Dir to open the List )
Maybe also possible, to use Wildcards like c_Path + "\Proj*" ?

Image

Code: Select all  Expand view

// c_path := GETCURDIR()

FUNCTION SUB_DIR()
local oDlg, oBrw, oTree, oFont, b

oTree := MakeTree()

DEFINE DIALOG oDlg SIZE 390,400 PIXEL ;
TITLE 'Select Directory' FONT oImgfont2 ;
STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME | WS_THICKFRAME

oDlg:SetBrush( oBrush2 )

@ 10,10 XBROWSE oBrw SIZE 165, 150 PIXEL OF oDlg NOBORDER

oBrw:SetTree( oTree )
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 := 'Project-Selection'
      b := :bLDClickData
      :bLDClickData  := { |r,c,f,o| ToggleFolder( r,c,f,o,b ) }
 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'

oBrw:CreateFromCode()

@ 165, 70 BTNBMP oBtn1 FILENAME c_path + "\Bitmaps\Close.bmp" ;
SIZE 60, 30 OF oDlg PIXEL NOBORDER 2007 ;
LEFT ;
PROMPT " &EXIT" ;
FONT oTxtfont ;
ACTION  oDlg:End()
oBtn1:cTooltip := "Exit Image-Viewer"
oBtn1:lTransparent := .T.
oBtn1:l2007 := .F.
oBtn1:SetColor( 0 )

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

TREEITEM oItem PROMPT c_Path  
oItem:Cargo := { c_Path + "\", 0, CtoD( '' ), Space( 8 ), 'D', c_Path + "\" }
oItem:bAction  := { |o| o:SetTree( SubTree( o ) ), o:bAction := NIL }

ENDTREE

RETURN OTREE

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

STATIC FUNCTION SUBTREE( oParent )
local oTree, n, oItem, nLevel, nItems := 0
local cFolder := oParent:Cargo[ 6 ], cSubDir
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 ]
            cSubDir := "
3"
            oItem:bAction  := { |o| o:SetTree( SubTree( o ) ), o:bACtion := MsgAlert( "
Project" ) }
        ENDIF
        nItems++
    ENDIF
NEXT

ENDTREE

RETURN oTree


Best Regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Possible with <cGetDir> select from a opend Main-Dir ?

Postby ukoenig » Fri Aug 03, 2012 1:11 pm

My final Solution.
It works fine now :

1. Names of a Projectpath are PROJECT1, PROJECT2 ...
2. I use the Function DIRECTORY and work with Wildcards like PROJECT*
3. xBrowse shows only these existing Subdirectorys.
4. Next I save the Project-path to a INI-file and relaunch the Prog with the new Project.
( The RESTART-Function comes from Daniel )
5. Maybe because of existing Files, I use < StrCharCount > to be sure, only Subdirectorys are selected.


Image

Code: Select all  Expand view

FUNCTION SUB_DIR()
LOCAL oDlg, oBrw, oBtn1, aFiles, aProject := {}, oBrush1

DEFINE BRUSH oBrush1 FILENAME c_path + "\Bitmaps\Stone.bmp"

// Wildcard on Subdir
//-------------------------
aFiles   := Directory( c_Path + "\PROJECT*.*", "D")
I := 3
FOR I := 3 TO LEN( aFiles)
    IF StrCharCount( aFiles[I][1], "." ) = 0
        AADD(aProject , { aFiles[I][1] } )
    ENDIF
NEXT

DEFINE DIALOG oDlg SIZE 300, 400 PIXEL ;
TITLE 'Select Directory' FONT oImgfont2 ;
STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME | WS_THICKFRAME

@ 10,10 XBROWSE oBrw SIZE 130, 150 PIXEL OF oDlg NOBORDER ;
ARRAY aProject FONT oImgfont2 ;
COLUMNS 1 ;
HEADERS "Project-Selection"

oBrw:lHeader := .T.
oBrw:lFooter := .F.
oBrw:lRecordSelector := .T.
oBrw:nHeaderHeight() := 50
oBrw:nRowHeight := 25
oBrw:bClrSelFocus = { || { , 16777215 } }  
oBrw:bClrSel = { || { 0, 16777215 } }  
oBrw:bClrStd  := {|| { 0, 16777215 } }
oBrw:bClrSelFocus = { || { 0, 16777215 } }  
oBrw:lHScroll := .F.
oBrw:aCols[ 1 ]:nWidth := 220

WITH OBJECT oBrw:aCols[ 1 ]
      :oHeaderFont := oTxtFont
      :AddBmpFile( c_path + "\Bitmaps\Preview.Bmp" )
      :nHeadBmpNo := 1
END

XBRW_BACK(oBrw)

// Saves the Subdir to a INI-file and RESTARTS
//-------------------------------------------------------------
oBrw:bLClicked := { | nRow, nCol | ;
    c_Path1 := aProject[oBrw:KeyNo()][1] + "\", ;
        SAVE_INI(), WINEXEC( "
RESTART ImgView.exe " + Str( oDlg1:hWnd ) ) }
                               
oBrw:CreateFromCode()

@ 165, 50 BTNBMP oBtn1 FILENAME c_path + "
\Bitmaps\Close.bmp" ;
SIZE 60, 30 OF oDlg PIXEL NOBORDER 2007 ;
LEFT ;
PROMPT "
&EXIT" ;
FONT oTxtfont ;
ACTION  oDlg:End()
oBtn1:cTooltip := "
Exit Project-Selection"
oBtn1:lTransparent := .T.
oBtn1:l2007 := .F.
oBtn1:SetColor( 0 )

ACTIVATE DIALOG oDlg CENTER ;
ON INIT oDlg:SetBrush( oBrush1 )

oBrush1:End()

RETURN NIL


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Possible with <cGetDir> select from a opend Main-Dir ?

Postby Enrico Maria Giordano » Fri Aug 03, 2012 5:35 pm

Try also:

Code: Select all  Expand view
cDirName := cGetDir( "Select a directory", "D:\P_xbrwimg_plan", , "Test", 3 )


Works fine here on XP.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 64 guests