Show a directry in TreeGadget

Just starting out? Need help? Post your questions and find answers here.
porfirio
Enthusiast
Enthusiast
Posts: 111
Joined: Mon Nov 15, 2004 11:00 pm
Location: portugal

Show a directry in TreeGadget

Post 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
Forgive-me for my english, i'm portuguese!
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Show a directry in TreeGadget

Post by PB »

> What i want is a TreeGadget that yould act like a ExplorerGadget

http://www.purebasic.com/documentation/ ... adget.html
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
porfirio
Enthusiast
Enthusiast
Posts: 111
Joined: Mon Nov 15, 2004 11:00 pm
Location: portugal

Re: Show a directry in TreeGadget

Post 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 :?
Forgive-me for my english, i'm portuguese!
josku_x
Addict
Addict
Posts: 997
Joined: Sat Sep 24, 2005 2:08 pm

Post 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?
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Well, he asked for an 'ExplorerTreeGadget() which display files too'. As ExplorerTreeGadget() already display the files, it can fit its needs.
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post 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
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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. :?:
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
porfirio
Enthusiast
Enthusiast
Posts: 111
Joined: Mon Nov 15, 2004 11:00 pm
Location: portugal

Post 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...
Forgive-me for my english, i'm portuguese!
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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)?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
porfirio
Enthusiast
Enthusiast
Posts: 111
Joined: Mon Nov 15, 2004 11:00 pm
Location: portugal

Post by porfirio »

I have already seen a program that do that
or mabe i am wrong

:roll:
Forgive-me for my english, i'm portuguese!
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post 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.
@}--`--,-- A rose by any other name ..
porfirio
Enthusiast
Enthusiast
Posts: 111
Joined: Mon Nov 15, 2004 11:00 pm
Location: portugal

Post by porfirio »

i founded id :D

Thank's!!
Forgive-me for my english, i'm portuguese!
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

porfirio wrote:i founded id :D Thank's!!
:roll: Would you enlighten us and tell which code serves your needs :?:
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Yes, please let us know what you found, as I'd like to see it too.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
porfirio
Enthusiast
Enthusiast
Posts: 111
Joined: Mon Nov 15, 2004 11:00 pm
Location: portugal

Post 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 
Forgive-me for my english, i'm portuguese!
Post Reply