Jump to content

Arrays and Gui tree


 Share

Recommended Posts

I'm basically trying to get this list menu to read from a .ini file which looks like

[Macro1]

Event1=

Event2=

Event3=

[Macro2]

Event1=

Event2=

Event3=

And I want to list each macro secation name as as a tree item and each key under that section as a sub branch with future expansion and changes being writen to the .ini file.

So far I can get it to write the section names into the tree list correctly but I'm having problems trying to use arrays to get the key data listed under the correct section. A few lines I set aside as things I've tried and do not work =\

Global $macroList[10], $macroListData[50]
#include <GUIConstants.au3>
#Include <Constants.au3>
#include <array.au3>

;===================================> GUI <=======================================

GUICreate("Macro  v1.0", 400, 430)
$filemenu = GUICtrlCreateMenu ("File")
$optionsmenu = GUICtrlCreateMenu ("Options")
$helpmenu = GUICtrlCreateMenu ("?")
$Fileitem = GUICtrlCreateMenuitem ("New",$filemenu)
$Fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)
$Fileitem = GUICtrlCreateMenuitem ("Save",$filemenu)
$Fileitem = GUICtrlCreateMenuitem ("Exit",$filemenu)

$btnNew = GUICtrlCreateButton("New", 335, 15, 60)
$btnSave = GUICtrlCreateButton("Save", 335, 45, 60)
$btnLoad = GUICtrlCreateButton("Load", 335, 75, 60)
$btnPlay = GUICtrlCreateButton("Play", 335, 115, 50)
$btnStop = GUICtrlCreateButton("Stop", 335, 145, 50)
$btnPause = GUICtrlCreateButton("Pause", 335, 175, 50)

$treeview = GUICtrlCreateTreeView (6,6,200,250,BitOr($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE)


GUISetState()
;================================> End GUI <======================================

createMenu()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop   

sleep(100)
WEnd


Func createMenu()
$var = IniReadSectionNames("testmacrolist.ini")

If @error Then 
    MsgBox(4096, "", "Error occured, probably no INI file.")
Else
    For $i = 1 To $var[0]
       $macroData = IniReadSection("testmacrolist.ini", $var[$i])
       _ArrayAdd($macroList, GUICtrlCreateTreeViewitem ($var[$i],$treeview))
       For $x = 1 To $macroData[0][0]
;     $macroListData = GUICtrlCreateTreeViewitem ($macroData[$x][0],$macroList)
;     MsgBox(4096, "", "Name: " & $var[$i] & @CRLF & "Key: " & $macroData[$x][0] & @CRLF & "Value: " & $MacroData[$x][1])
       Next
    Next
EndIf

;_ArrayAdd($macroListData, GUICtrlCreateTreeViewitem ($macroData[$x][0],$var[$i])
EndFunc
Link to comment
Share on other sites

is your problem that you can't get the GUI functions working the way you want - GUI Support ? or that you can't figure out how to use Ini* functions?

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

Global $macrolist[10], $macrolistdata[50]
#include <GUIConstants.au3>
#Include <Constants.au3>
#include <array.au3>

;===================================> GUI <=======================================

GUICreate("Macro  v1.0", 400, 430)
$filemenu = GUICtrlCreateMenu("File")
$optionsmenu = GUICtrlCreateMenu("Options")
$helpmenu = GUICtrlCreateMenu("?")
$fileitem = GUICtrlCreateMenuItem("New", $filemenu)
$fileitem = GUICtrlCreateMenuItem("Open", $filemenu)
$fileitem = GUICtrlCreateMenuItem("Save", $filemenu)
$fileitem = GUICtrlCreateMenuItem("Exit", $filemenu)

$btnnew = GUICtrlCreateButton("New", 335, 15, 60)
$btnsave = GUICtrlCreateButton("Save", 335, 45, 60)
$btnload = GUICtrlCreateButton("Load", 335, 75, 60)
$btnplay = GUICtrlCreateButton("Play", 335, 115, 50)
$btnstop = GUICtrlCreateButton("Stop", 335, 145, 50)
$btnpause = GUICtrlCreateButton("Pause", 335, 175, 50)

$treeview = GUICtrlCreateTreeView(6, 6, 200, 250, BitOR($tvs_hasbuttons, $tvs_haslines, $tvs_linesatroot, $tvs_disabledragdrop, $tvs_showselalways), $ws_ex_clientedge)
$sections = IniReadSectionNames("testmacrolist.ini")    
    If @error Then
        MsgBox(4096, "", "Error occured, probably no INI file.")
    Else
        For $i = 1 To $sections[0]
            $keys = IniReadSection("testmacrolist.ini", $sections[$i])
            $item = GUICtrlCreateTreeViewItem($sections[$i], $treeview)
            For $x = 1 To $keys[0][0]
                GUICtrlCreateTreeViewItem($keys[$x][0], $item)
            Next
        Next
    EndIf

GUISetState()
;================================> End GUI <======================================

;createMenu()

While 1
    $msg = GUIGetMsg()
    If $msg = $gui_event_close Then ExitLoop
    
    Sleep(100)
WEnd

I hope this helps.

.

Link to comment
Share on other sites

Global $macrolist[10], $macrolistdata[50]
#include <GUIConstants.au3>
#Include <Constants.au3>
#include <array.au3>

;===================================> GUI <=======================================

GUICreate("Macro  v1.0", 400, 430)
$filemenu = GUICtrlCreateMenu("File")
$optionsmenu = GUICtrlCreateMenu("Options")
$helpmenu = GUICtrlCreateMenu("?")
$fileitem = GUICtrlCreateMenuItem("New", $filemenu)
$fileitem = GUICtrlCreateMenuItem("Open", $filemenu)
$fileitem = GUICtrlCreateMenuItem("Save", $filemenu)
$fileitem = GUICtrlCreateMenuItem("Exit", $filemenu)

$btnnew = GUICtrlCreateButton("New", 335, 15, 60)
$btnsave = GUICtrlCreateButton("Save", 335, 45, 60)
$btnload = GUICtrlCreateButton("Load", 335, 75, 60)
$btnplay = GUICtrlCreateButton("Play", 335, 115, 50)
$btnstop = GUICtrlCreateButton("Stop", 335, 145, 50)
$btnpause = GUICtrlCreateButton("Pause", 335, 175, 50)

$treeview = GUICtrlCreateTreeView(6, 6, 200, 250, BitOR($tvs_hasbuttons, $tvs_haslines, $tvs_linesatroot, $tvs_disabledragdrop, $tvs_showselalways), $ws_ex_clientedge)
$sections = IniReadSectionNames("testmacrolist.ini")    
    If @error Then
        MsgBox(4096, "", "Error occured, probably no INI file.")
    Else
        For $i = 1 To $sections[0]
            $keys = IniReadSection("testmacrolist.ini", $sections[$i])
            $item = GUICtrlCreateTreeViewItem($sections[$i], $treeview)
            For $x = 1 To $keys[0][0]
                GUICtrlCreateTreeViewItem($keys[$x][0], $item)
            Next
        Next
    EndIf

GUISetState()
;================================> End GUI <======================================

;createMenu()

While 1
    $msg = GUIGetMsg()
    If $msg = $gui_event_close Then ExitLoop
    
    Sleep(100)
WEnd

I hope this helps.

<{POST_SNAPBACK}>

Damn, thanks a lot I had some things very close to that but non would work I think I understand my errors tho. Thanks!
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...