Page 1 of 2

Show a directry in TreeGadget

Posted: Thu Jan 12, 2006 7:08 pm
by porfirio
Hi!

I am building a small app to show help files

The Files are html and will be organized in folders

What i want is a TreeGadget that yould act like a ExplorerGadget but showing the files in the Tree too ( kinda what winhelp have )

I have tryed to use ExamineDirectory and create a field for etch file\folder but i got losted :s

If some one can help i will be glad :)

Edit:
I will use a webgadgect to display the files

Re: Show a directry in TreeGadget

Posted: Thu Jan 12, 2006 8:18 pm
by PB
> What i want is a TreeGadget that yould act like a ExplorerGadget

http://www.purebasic.com/documentation/ ... adget.html

Re: Show a directry in TreeGadget

Posted: Thu Jan 12, 2006 9:27 pm
by porfirio
PB wrote:> What i want is a TreeGadget that yould act like a ExplorerGadget

http://www.purebasic.com/documentation/ ... adget.html
One of us is not understanding :?

Posted: Fri Jan 13, 2006 9:34 pm
by josku_x
PB, porfirio wants to have a TeeGadget that is like a ExplorerTreeGadget, so it lists the contents of a directory etc...
but porfirio doesn't want a ExplorerTreeGadget!

is that right?

Posted: Fri Jan 13, 2006 10:09 pm
by Fred
Well, he asked for an 'ExplorerTreeGadget() which display files too'. As ExplorerTreeGadget() already display the files, it can fit its needs.

Posted: Sat Jan 14, 2006 12:03 am
by fsw
porfirio wrote:One of us is not understanding :?
:?

Code: Select all

  If OpenWindow(0,0,0,300,300,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"ExplorerTreeGadget") And CreateGadgetList(WindowID(0))
    ExplorerTreeGadget(0, 10, 10, 280, 280, "*.htm;*.html")
    Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
  EndIf
:D

Posted: Sat Jan 14, 2006 12:42 am
by PB
> porfirio doesn't want a ExplorerTreeGadget!

He never said that. From his description, an ExplorerTreeGadget is precisely
what he needs, ie. a tree-type gadget that can list files (to quote:
a TreeGadget that yould act like a ExplorerGadget but showing the files in the
Tree too
).

And also: there's no such thing as an "ExplorerGadget" in PureBasic, so I
don't know where he's getting that from. :?:

Posted: Sat Jan 14, 2006 11:14 am
by porfirio
I dont want to show all windows tree i want to show just a tree begining on some folder and i want it to dysplay the html files too and not only the folders

i think i have to make my own using examinedirectory and a treegadgect but i got some problems :cry:

Edit:
*fsw is kinda that what i want :lol: but it should not show all tree directory but only the tree after the folder specified

Code: Select all

  If OpenWindow(0,0,0,300,300,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"ExplorerTreeGadget") And CreateGadgetList(WindowID(0))
    ExplorerTreeGadget(0, 10, 10, 280, 280, "help\*.html")
    Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
  EndIf 
I have seen that somewhere...

Posted: Sat Jan 14, 2006 11:59 am
by PB
> fsw is kinda that what i want

Just like I said first. ;)

> but it should not show all tree directory but only the tree after the folder specified

Well, only the ExplorerListGadget can do that (due to the #PB_Explorer_NoFolders
and #PB_Explorer_NoParentFolder flags), but unfortunately that means you don't
get a "tree" view. But the ExplorerTreeGadget doesn't support those flags, and I
don't know if it's a Windows limitation or Fred not implementing them yet... Fred?

Or maybe someone knows how to make the ExplorerListGadget have a "tree"
view also (perhaps by way of some kind of Windows API flag or hack)?

Posted: Sat Jan 14, 2006 12:08 pm
by porfirio
I have already seen a program that do that
or mabe i am wrong

:roll:

Posted: Sat Jan 14, 2006 1:48 pm
by Dare2
I am fairly sure there is code that does what you want at www.purearea.net - in the code archive.

If not there, on these boards.

IIRC it uses the ExplorerComboGadget and a TreeGadget to give a windows-explorer like look.

Posted: Sat Jan 14, 2006 7:55 pm
by porfirio
i founded id :D

Thank's!!

Posted: Sat Jan 14, 2006 11:14 pm
by fsw
porfirio wrote:i founded id :D Thank's!!
:roll: Would you enlighten us and tell which code serves your needs :?:

Posted: Sun Jan 15, 2006 12:24 am
by PB
Yes, please let us know what you found, as I'd like to see it too.

Posted: Sun Jan 15, 2006 12:07 pm
by porfirio
Original code on CodeArchieve
http://purearea.net/pb/CodeArchiv/Files ... le_Tree.pb

My current code:

Code: Select all

#Tree = 1 
#web=2

folder=LoadImage(0,"f.bmp")
filehtml=LoadImage(1,"i.bmp")
Procedure DirScan(DirectoryID.l, DirectoryName.s) 
  OpenTreeGadgetNode(#Tree) 
  If ExamineDirectory(DirectoryID, DirectoryName, "*.*") 
    Repeat 
      entry.l = NextDirectoryEntry() 
      If entry = 1   
        dname.s=DirectoryEntryName()
        dname_.s=ReplaceString(dname,"html","")
        If dname_<>dname ;And dname_<>"index"
          AddGadgetItem(#Tree, -1, dname_,UseImage(1)) ;(FileName found) 
        EndIf 
      ElseIf entry = 2 
        name.s = DirectoryEntryName() 
        If name <> "." And name <> ".." And name <> "core"
          While WindowEvent():Wend 
          AddGadgetItem(#Tree, -1, name,UseImage(0)) 
          DirScan(DirectoryID + 1, DirectoryName + name + "\") 
          UseDirectory(DirectoryID) 
        EndIf 
      EndIf 
    Until entry = 0 
  EndIf 
  CloseTreeGadgetNode(#Tree) 
EndProcedure 

OpenWindow(0, 0, 0, 800, 600, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Dir Scan...") 
CreateGadgetList(WindowID()) 
TreeGadget(#Tree,  2,  2, 230, 580) 
WebGadget(#web,234,3,560,580,"")
CreateStatusBar(0,WindowID())
DirScan(0, "help\") 

Repeat 
  EventID = WaitWindowEvent() 
    If EventID = #PB_EventGadget 
      Select EventGadgetID() 
        Case #Tree 
          If EventType() = #PB_EventType_LeftClick And GetGadgetState(#Tree) <> -1 
            CurrentLine = GetGadgetState(#Tree) 
            ;MessageRequester(Str(CurrentLine),GetGadgetText(#Tree))
            item.s =GetGadgetText(#Tree)
            item_.s= ReplaceString(item,".","")
            If item<>item_
              MessageRequester("","Its a File!!")
            Else
                MessageRequester("","Its a Folder!!")
            EndIf
            ;GetCurrentDirectory()
          EndIf  
      EndSelect 
    EndIf 
Until EventID = #PB_EventCloseWindow 
End