Jump to content

Help with treeitems in treeview!


Glyph
 Share

Recommended Posts

#include <GUIConstants.au3>
#Include <File.au3>
#Include <Array.au3>
#include <GuiTreeView.au3>
#NoTrayIcon
    Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown.
$showitem      = TrayCreateItem("Un-Tray")
    TrayCreateItem("")
$aboutitem      = TrayCreateItem("About")
    TrayCreateItem("")
$exititem       = TrayCreateItem("Exit")
    TraySetState()
    
Global $ini=@HomeDrive&"\Program Files\Ethernet\EServer\EWSMT.ini"
Global $Width = IniRead ($ini, "EWSMT", "Width", 200)
Global $Height = IniRead ($ini, "EWSMT", "Height", @DesktopHeight/2)

If $Width<175 OR $Width>@DesktopWidth-20 Then $Width=200
If $Height<100 OR $Height>@DesktopHeight-100 Then $Height=@DesktopHeight/2
    
$gui1=GUICreate("EWSMT v0.1 by: Ethernet",$Width,$Height,0,0,$WS_SIZEBOX)
    GUISetBkColor(0x000000)
    

$filemenu = GuiCtrlCreateMenu ("File")
$tray = GUICtrlCreateMenuItem ("Tray",$filemenu)
$exits = GUICtrlCreateMenuItem ("Exit",$filemenu)

$tree = GuiCtrlCreateTreeView(2, 37, $Width-5, $Height-78, BitOr($TVS_HASLINES,$TVS_LINESATROOT,$TVS_HASBUTTONS), $WS_EX_CLIENTEDGE)

    GUICtrlSetResizing(-1,BitOr($GUI_DOCKTOP,$GUI_DOCKBOTTOM))
    GUICtrlSetImage(-1, "shell32.dll", -151, 4) 
    
$contextmenu = GUICtrlCreateContextMenu ($tree)
$first = GUICtrlCreateTreeViewitem(".::EServer v1.2::.", $tree)

_GUICtrlTreeViEWSetBkColor ($tree, 0x000000)
_GUICtrlTreeViEWSetTextColor ($tree, 0xff0000)

$s_Command="dir """&@HomeDrive&"\Program Files\Ethernet\EServer\*"" /og /s /b >"&@HomeDrive&"\EserverDir.txt"
    RunWait(@ComSpec & ' /c ' & $s_Command, '', @SW_HIDE)

$x=_FileCountLines (@HomeDrive&"\EserverDir.txt")
$file=@HomeDrive&"\EserverDir.txt"

Dim $browse[$x]

$i=0
GUICtrlCreateTreeViewitem(".::Only the first file works!::.", $first)
        _GUICtrlTreeViEWSetIcon($tree, -1, "shell32.dll", -235)
        
Dim $browse
$browse = _ArrayCreate("Directory");0

Dim $item
$item = _ArrayCreate("Tree");0

do 
    $i=$i + 1
    $t=FileReadLine($file,$i)
    $duh=StringTrimLeft($t,33)
    $a=GUICtrlCreateTreeViewitem($duh, $first)
_GUICtrlTreeViEWSetIcon($tree, $a, "shell32.dll", -133)
;$aa=GUICtrlCreateMenuitem ($duh,$contextmenu)
_ArrayAdd($browse,$t)
_ArrayAdd($item,$a)
until $i = $x

$i=0

GuiSetState()
While 1
    $msg = GUIGetMsg()
    $msg2=TrayGetMsg()
    Select
    case $msg = $GUI_EVENT_CLOSE or $msg = $exits
         $Size=WinGetClientSize($gui1)
         IniWrite($ini, "EWSMT", "Width", $Size[0]+2)
         IniWrite($ini, "EWSMT", "Height", $Size[1]+48)
         ExitLoop
        
    case $msg = $item[1]
        ShellExecute($browse[1])
        
    case $msg = $tray
        GUISetState(@SW_HIDE,$gui1)
        
    case $msg2 = 0
        ContinueLoop
            
    case $msg2 = $aboutitem 
        Msgbox(64,"about:","Ethernet Web Server Managment Tool v0.1 by: Ethernet"&@crlf&"http://ethernet.ath.cx")
            
    case $msg2 = $exititem
        Exit
    case $msg2 = $showitem
        GUISetState(@SW_SHOW,$gui1)
    EndSelect

WEnd
;ExitLoop
GUIDelete()
Exit

I only have it working for 1 set number in the array.

How would I get it to work for each one?

I tried many functions, but I havn't found anything that worked, "for next, if then, case, etc.."...

Edited by BackStabbed

tolle indicium

Link to comment
Share on other sites

  • Developers

ever considered that the questions isn't clear ? bumping it won't make any more clear ... :)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Please, tell me if there's something you don't understand!

Anyone?

I have considered that, what don't you understand though? I reread this over and over and it makes sense to me...

Edited by BackStabbed

tolle indicium

Link to comment
Share on other sites

ok... I got this to work for me

I strongly suggest you get and use Autoit Beta, there are alot more controls and options

I am on Beta 3.2.9.14

#include <GUIConstants.au3>
#Include <File.au3>
#Include <Array.au3>
#include <GuiTreeView.au3>
#NoTrayIcon


    Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown.
$showitem      = TrayCreateItem("Un-Tray")
    TrayCreateItem("")
$aboutitem      = TrayCreateItem("About")
    TrayCreateItem("")
$exititem       = TrayCreateItem("Exit")
    TraySetState()
   
Global $ini=@HomeDrive&"\Program Files\Ethernet\EServer\EWSMT.ini"
Global $Width = IniRead ($ini, "EWSMT", "Width", 200)
Global $Height = IniRead ($ini, "EWSMT", "Height", @DesktopHeight/2)

If $Width<175 OR $Width>@DesktopWidth-20 Then $Width=200
If $Height<100 OR $Height>@DesktopHeight-100 Then $Height=@DesktopHeight/2
   
$gui1=GUICreate("EWSMT v0.1 by: Ethernet");,$Width,$Height,0,0,$WS_SIZEBOX)
    GUISetBkColor(0x000000)
   

$filemenu = GuiCtrlCreateMenu ("File")
$tray = GUICtrlCreateMenuItem ("Tray",$filemenu)
$exits = GUICtrlCreateMenuItem ("Exit",$filemenu)

$tree = GuiCtrlCreateTreeView(2, 37, $Width-5, $Height-78, BitOr($TVS_HASLINES,$TVS_LINESATROOT,$TVS_HASBUTTONS), $WS_EX_CLIENTEDGE)

    GUICtrlSetResizing(-1,BitOr($GUI_DOCKTOP,$GUI_DOCKBOTTOM))
    GUICtrlSetImage(-1, "shell32.dll", -151, 4)
   
$contextmenu = GUICtrlCreateContextMenu ($tree)
$first = GUICtrlCreateTreeViewitem(".::EServer v1.2::.", $tree)

_GUICtrlTreeViEW_SetBkColor ($tree, 0x000000)
_GUICtrlTreeView_SetTextColor ($tree, 0xff0000)

$s_Command="dir """&@HomeDrive&"\Program Files\Autoit3\SciTE\*"" /og /s /b >"&@HomeDrive&"\EserverDir.txt" ; for testing

;$s_Command="dir """&@HomeDrive&"\Program Files\Ethernet\EServer\*"" /og /s /b >"&@HomeDrive&"\EserverDir.txt"
    RunWait(@ComSpec & ' /c ' & $s_Command, '', @SW_HIDE)

$x=_FileCountLines (@HomeDrive&"\EserverDir.txt")
MsgBox(0,0,"x=" & $x, 1)
$file=@HomeDrive&"\EserverDir.txt"

;Dim $browse[$x]

$i=0
GUICtrlCreateTreeViewitem(".::Only the first file works!::.", $first)
        _GUICtrlTreeViEW_SetIcon($tree, -1, "shell32.dll", -235)
       
Dim $browse
$browse = _ArrayCreate("Directory");0

Dim $item
$item = _ArrayCreate("Tree");0
GuiSetState()
do
    $i=$i + 1
    $t=FileReadLine($file,$i)
    $duh=StringTrimLeft($t,33)
    $a=GUICtrlCreateTreeViewitem($duh, $first)
_GUICtrlTreeViEW_SetIcon($tree, $a, "shell32.dll", -133)
$aa=GUICtrlCreateMenuitem ($duh,$contextmenu)
_ArrayAdd($browse,$t)
_ArrayAdd($item,$a)
ToolTip($i &"  " &$x, 20, 20)
until $i = $x
Sleep(800)
ToolTip("")

$i=0

;GuiSetState()
While 1
    $msg = GUIGetMsg()
    $msg2=TrayGetMsg()
    
    for $x = 1 to UBound($item) -1
        If $msg = $item[$x] Then ShellExecute($browse[$x])
    Next
    
    
    Select
    case $msg = $GUI_EVENT_CLOSE or $msg = $exits
         $Size=WinGetClientSize($gui1)
         IniWrite($ini, "EWSMT", "Width", $Size[0]+2)
         IniWrite($ini, "EWSMT", "Height", $Size[1]+48)
         ExitLoop
       
    ;case $msg = $item[2]
    ;    ShellExecute($browse[2])
       
    case $msg = $tray
        GUISetState(@SW_HIDE,$gui1)
       
    case $msg2 = 0
        ContinueLoop
           
    case $msg2 = $aboutitem
        Msgbox(64,"about:","Ethernet Web Server Managment Tool v0.1 by: Ethernet"&@crlf&"http://ethernet.ath.cx")
           
    case $msg2 = $exititem
        Exit
    case $msg2 = $showitem
        GUISetState(@SW_SHOW,$gui1)
    EndSelect
 
WEnd
;ExitLoop
GUIDelete()
Exit

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...