AutoHotkey Community

It is currently May 26th, 2012, 4:38 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: March 30th, 2009, 5:57 am 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
having difficulty understanding how to populate a treeview with folders and files.

what is wrong here

Code:
AddSubFoldersToTree(Folder, ParentItemID = 0)
{
    ; This function adds to the TreeView all subfolders in the specified folder.
    ; It also calls itself recursively to gather nested folders to any depth.
    ;---------------------------------------------------------------------------
    Loop %Folder%\*.*, 2  ; Retrieve all of Folder's sub-folders.
    {
      
      ; show files
      ;------------
      Loop %A_LoopFileFullPath%\*.*   
      {
         if ( (instr(A_LoopFileName, ".htm",CaseSensitive = false) > 0) or (instr(A_LoopFileName, ".html",CaseSensitive = false) > 0)   )
         {

            ParentID := TV_GetParent(ParentID)            
            ID := "P" .  ParentID  . "C" . A_Index
            
            msgbox, %A_LoopFileFullPath%  %ID%
            
            ID = TV_Add(  A_LoopFileName, ParentID)
         }
      }
      
    ParentItemID ++
      
    ;recurse folders
    ;----------------
    AddSubFoldersToTree(A_LoopFileFullPath, TV_Add(A_LoopFileName, ParentItemID, "Icon4"))

   }
}


________
ZX14 VS HAYABUSA


Last edited by webber on March 11th, 2011, 12:33 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 30th, 2009, 7:15 am 
Offline

Joined: May 3rd, 2007, 5:59 am
Posts: 24
G'day Webber,

Without bothering with the icons at all...

Code:
Gui, Add, TreeView, w300 r20
SplitPath, A_AhkPath,, ExamplePath
AddSubFolderToTree(ExamplePath)
Gui, Show, Center, File List TreeView
Return

GuiClose:
ExitApp

AddSubFolderToTree(Folder, ParentItemID = 0)
{
  Loop %Folder%\*.*, 2
  {
    ID := TV_Add(A_LoopFileName, ParentItemID)
    AddSubFolderToTree(A_LoopFileFullPath, ID)
  }
  Loop %Folder%\*.*
    ID := TV_Add(A_LoopFileName, ParentItemID)
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2009, 3:53 am 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
LBJ wrote:
G'day Webber,

Without bothering with the icons at all...

Code:
Gui, Add, TreeView, w300 r20
SplitPath, A_AhkPath,, ExamplePath
AddSubFolderToTree(ExamplePath)
Gui, Show, Center, File List TreeView
Return

GuiClose:
ExitApp

AddSubFolderToTree(Folder, ParentItemID = 0)
{
  Loop %Folder%\*.*, 2
  {
    ID := TV_Add(A_LoopFileName, ParentItemID)
    AddSubFolderToTree(A_LoopFileFullPath, ID)
  }
  Loop %Folder%\*.*
    ID := TV_Add(A_LoopFileName, ParentItemID)
}



Accepted Solution
________
Ship Sale


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Miguel, notsoobvious, Yahoo [Bot] and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group