[a104] Error with treeview control after install new release. Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
quaritexa
Posts: 32
Joined: 09 Nov 2017, 21:03

[a104] Error with treeview control after install new release.

Post by quaritexa » 18 Aug 2019, 13:13

190818194446.png
190818194446.png (7.43 KiB) Viewed 2460 times

Code: Select all

  aiScriptsResize(this, MinMax, Width, Height) {
    global
    if MinMax = -1
      return
    this.Control["aiScriptsTree"].Move("w" Width " h" Height)
  }

User avatar
kczx3
Posts: 1649
Joined: 06 Oct 2015, 21:39

Re: [a104] Error with treeview control after install new release.

Post by kczx3 » 18 Aug 2019, 16:52

Are you supposed to define ‘this’ as an actual parameter?

Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [a104] Error with treeview control after install new release.  Topic is solved

Post by Helgef » 19 Aug 2019, 02:15

The control property was removed, use gui.__item instead, i.e., gui['name']. I only found non-working links to it, but it is documented here :arrow: gui.__item.

Cheers.

User avatar
Maestr0
Posts: 136
Joined: 05 Dec 2013, 17:43

Re: [a104] Error with treeview control after install new release.

Post by Maestr0 » 19 Aug 2019, 13:52

I just had the same error and figured out how to fix it.... and then I found this thread so I'll just post it here ;)

anyway, this works:

I'd changed the .Control parts and replaced {} with Map()

Code: Select all

; The following folder will be the root folder for the TreeView. Note that loading might take a long
; time if an entire drive such as C:\ is specified:
TreeRoot := A_MyDocuments
TreeViewWidth := 280
ListViewWidth := A_ScreenWidth/2 - TreeViewWidth - 30

; Create the GUI window and display the source directory (TreeRoot) in the title bar:
Gui := GuiCreate("+Resize", TreeRoot)  ; Allow the user to maximize or drag-resize the window.

; Create an ImageList and put some standard system icons into it:
ImageListID := IL_Create(5)
Loop 5 
    IL_Add(ImageListID, "shell32.dll", A_Index)
; Create a TreeView and a ListView side-by-side to behave like Windows Explorer:
TV := Gui.Add("TreeView", "r20 w" TreeViewWidth " ImageList" ImageListID " vTV")
LV := Gui.Add("ListView", "r20 w" ListViewWidth " x+10 vLV", "Name|Modified")

; Create a Status Bar to give info about the number of files and their total size:
SB := Gui.Add("StatusBar", "vSB")
SB.SetParts(60, 85)  ; Create three parts in the bar (the third part fills all the remaining width).

; Add folders and their subfolders to the tree. Display the status in case loading takes a long time:
M := GuiCreate("ToolWindow -SysMenu", "Loading the tree..."), M.Show()
DirList := AddSubFoldersToTree(TV, TreeRoot, Map())
M.Hide()

; Call TV_ItemSelect whenever a new item is selected:
TV.OnEvent("ItemSelect", Func("TV_ItemSelect").bind(DirList))

; Call Gui_Size whenever the window is resized:
Gui.OnEvent("Size", "Gui_Size")

; Set the ListView's column widths (this is optional):
Col2Width := 70  ; Narrow to reveal only the YYYYMMDD part.
LV.ModifyCol(1, ListViewWidth - Col2Width - 30)  ; Allows room for vertical scrollbar.
LV.ModifyCol(2, Col2Width)

; Display the window. The OS will notify the script whenever the user performs an eligible action:
Gui.Show
return

AddSubFoldersToTree(TV, Folder, DirList, ParentItemID := 0)
{
    ; This function adds to the TreeView all subfolders in the specified folder
    ; and saves their paths associated with an ID into an object for later use.
    ; It also calls itself recursively to gather nested folders to any depth.
    Loop Files, Folder "\*.*", "D"  ; Retrieve all of Folder's sub-folders.
    {
        ItemID := TV.Add(A_LoopFileName, ParentItemID, "Icon4")
        DirList[ItemID] := A_LoopFilePath
        DirList := AddSubFoldersToTree(TV, A_LoopFilePath, DirList, ItemID)
    }
    return DirList
}

TV_ItemSelect(DirList, TV, Item)  ; This function is called when a new item is selected.
{
    ; Put the files into the ListView:
    LV := TV.Gui["LV"]
    LV.Delete  ; Clear all rows.
    LV.Opt("-Redraw")  ; Improve performance by disabling redrawing during load.
    TotalSize := 0  ; Init prior to loop below.
    Loop Files, DirList[Item] "\*.*"  ; For simplicity, omit folders so that only files are shown in the ListView.
    {
        LV.Add(, A_LoopFileName, A_LoopFileTimeModified)
        TotalSize += A_LoopFileSize
    }
    LV.Opt("+Redraw")

    ; Update the three parts of the status bar to show info about the currently selected folder:
    SB := TV.Gui["SB"]
    SB.SetText(LV.GetCount() " files", 1)
    SB.SetText(Round(TotalSize / 1024, 1) " KB", 2)
    SB.SetText(DirList[Item], 3)
}

Gui_Size(this, MinMax, Width, Height)  ; Expand/Shrink ListView and TreeView in response to the user's resizing.
{
    if MinMax = -1  ; The window has been minimized.  No action needed.
        return
    ; Otherwise, the window has been resized or maximized. Resize the controls to match.
    this["TV"].Move("H" Height - 30)  ; -30 for StatusBar and margins.
    this["LV"].Move("H" Height - 30 " W" Width - this["TV"].Pos.W - 30)
}

Post Reply

Return to “Ask for Help (v2)”