Jump to content

Creating a tree based on an ini file, asap! Thanks!


CrewXp
 Share

Recommended Posts

The Code Below was posted by Valuater, IT WORKS! But for some reason, when I click in the box to change it and click save, it doesn't save right. The code posted below doesn't have a code to save it, because mine isn't working. So I trashed mine. This is a clean code.

ALSO: It seems when I click other sub-items in the tree and click View, it shows the data, but when I click to change it, it goes back to the same data I changed it to in the beginning. There's no way to automatically get the data when I click the sub-item, instead of clicking View? Thanks

So in all 3 things

1.) Button to save

2.) Data Boxes change when I click them

3.) There's no way to automatically get the data when I click the sub-item, instead of clicking View (maybe that will solve #2)

this worked

Global $macrolist[10], $macrolistdata[50]
#include <GUIConstants.au3>
#Include <Constants.au3>
#include <array.au3>
; need this for my testing..... ok???
Dim $Location = "C:\Temp\sections.ini"
Dim $Location2 = "C:\Temp\pagedetails.ini"

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

GUICreate("Macro v1.0", 400, 460)
$filemenu = GUICtrlCreateMenu("File")
$optionsmenu = GUICtrlCreateMenu("Options")
$helpmenu = GUICtrlCreateMenu("?")
$fileitem = GUICtrlCreateMenuItem("Exit", $filemenu)
$button = GUICtrlCreateButton("New", 335, 15, 60)

$btnsave = GUICtrlCreateButton("Save", 335, 145, 60)
$treeview = GUICtrlCreateTreeView(6, 6, 200, 250, BitOR($tvs_hasbuttons, $tvs_haslines, $tvs_linesatroot, $tvs_disabledragdrop, $tvs_showselalways), $ws_ex_clientedge)
$sections = IniReadSectionNames($Location)
If @error Then
    MsgBox(4096, "", "Error occured, probably no INI file.")
Else
    For $i = 1 To $sections[0]
        $keys = IniReadSection($Location, $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 <======================================
While 1
    $msg = GUIGetMsg()
    
    Select
;Case $msg = -3 Or $msg = -1 Or $msg = $cancelbutton
        Case $msg = $gui_event_close
            ExitLoop
        Case $msg = $button
            Call("Set_PageDetails")
            
    EndSelect
    
    Sleep(10)
    
WEnd
; ------------------------------- Functions --------------------------------

Func Set_PageDetails()
; read the selection
    $item1 = GUICtrlRead($treeview)
    $item2 = GUICtrlRead($item1, 1)
    
; read the ini portion rerquested
    $name = IniRead($Location2, $item2[0], "Name", "NotFound")
    $page = IniRead($Location2, $item2[0], "Page", "NotFound")
    $topic = IniRead($Location2, $item2[0], "Topic", "NotFound")
    $status = IniRead($Location2, $item2[0], "UserStatus", "NotFound")
    $editstatus = IniRead($Location2, $item2[0], "EditStatus", "NotFound")
    $duedate = IniRead($Location2, $item2[0], "Due", "NotFound")
    
; display the info just read
    GUICtrlCreateLabel("Assigned To: ", 10, 280, 100, 20, 0x1000)
    GUICtrlCreateInput($name, 10, 300, 100, 20)
    GUICtrlCreateLabel("Page #: ", 120, 280, 100, 20, 0x1000)
    GUICtrlCreateInput($page, 120, 300, 100, 20)
    GUICtrlCreateLabel("Topic: ", 10, 330, 100, 20, 0x1000)
    GUICtrlCreateInput($topic, 10, 350, 100, 20)
    GUICtrlCreateLabel("Status: ", 120, 330, 100, 20, 0x1000)
    GUICtrlCreateInput($status, 120, 350, 100, 20)
    GUICtrlCreateLabel("EditStatus: ", 10, 380, 100, 20, 0x1000)
    GUICtrlCreateInput($editstatus, 10, 400, 100, 20)
    GUICtrlCreateLabel("DUE: ", 120, 380, 100, 20, 0x1000)
    GUICtrlCreateInput($duedate, 120, 400, 100, 20)
EndFunc;==>Set_PageDetails

8)

edit

cleaned it up 8)

Link to comment
Share on other sites

Global $macrolist[10], $macrolistdata[50]
#include <GUIConstants.au3>
#Include <Constants.au3>
#include <array.au3>
; need this for my testing..... ok???
Dim $Location = "C:\Temp\sections.ini"
Dim $Location2 = "C:\Temp\pagedetails.ini"
Dim $1st_run = 0, $namer, $pager, $topicer, $statuser, $editstatuser, $duedater, $item2
;===================================> GUI <=======================================

GUICreate("Macro v1.0", 400, 460)
$filemenu = GUICtrlCreateMenu("File")
$optionsmenu = GUICtrlCreateMenu("Options")
$helpmenu = GUICtrlCreateMenu("?")
$fileitem = GUICtrlCreateMenuItem("Exit", $filemenu)
$button = GUICtrlCreateButton("View", 335, 15, 60)

$btnsave = GUICtrlCreateButton("Save", 335, 145, 60)
$treeview = GUICtrlCreateTreeView(6, 6, 200, 250, BitOR($tvs_hasbuttons, $tvs_haslines, $tvs_linesatroot, $tvs_disabledragdrop, $tvs_showselalways), $ws_ex_clientedge)
$sections = IniReadSectionNames($Location)
If @error Then
MsgBox(4096, "", "Error occured, probably no INI file.")
Else
For $i = 1 To $sections[0]
$keys = IniReadSection($Location, $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 <======================================
While 1
$msg = GUIGetMsg()

Select
;Case $msg = -3 Or $msg = -1 Or $msg = $cancelbutton
Case $msg = $gui_event_close
ExitLoop
Case $msg = $button
Call("Set_PageDetails")
Case $msg = $btnsave
Call("Set_SaveDetails")
EndSelect

Sleep(10)

WEnd
; ------------------------------- Functions --------------------------------

Func Set_PageDetails()
; read the selection
$item1 = GUICtrlRead($treeview)
$item2 = GUICtrlRead($item1, 1)

; read the ini portion rerquested
$name = IniRead($Location2, $item2[0], "Name", "NotFound")
$page = IniRead($Location2, $item2[0], "Page", "NotFound")
$topic = IniRead($Location2, $item2[0], "Topic", "NotFound")
$status = IniRead($Location2, $item2[0], "UserStatus", "NotFound")
$editstatus = IniRead($Location2, $item2[0], "EditStatus", "NotFound")
$duedate = IniRead($Location2, $item2[0], "Due", "NotFound")

; display the info just read for first time
If $1st_run = 0 Then
    GUICtrlCreateLabel("Assigned To: ", 10, 280, 100, 20, 0x1000)
    $namer = GUICtrlCreateInput($name, 10, 300, 100, 20)
    GUICtrlCreateLabel("Page #: ", 120, 280, 100, 20, 0x1000)
    $pager = GUICtrlCreateInput($page, 120, 300, 100, 20)
    GUICtrlCreateLabel("Topic: ", 10, 330, 100, 20, 0x1000)
    $topicer = GUICtrlCreateInput($topic, 10, 350, 100, 20)
    GUICtrlCreateLabel("Status: ", 120, 330, 100, 20, 0x1000)
    $statuser = GUICtrlCreateInput($status, 120, 350, 100, 20)
    GUICtrlCreateLabel("EditStatus: ", 10, 380, 100, 20, 0x1000)
    $editstatuser = GUICtrlCreateInput($editstatus, 10, 400, 100, 20)
    GUICtrlCreateLabel("DUE: ", 120, 380, 100, 20, 0x1000)
    $duedater = GUICtrlCreateInput($duedate, 120, 400, 100, 20)
    $1st_run = 1
    Return
EndIf

GUICtrlSetData($namer, $name)
GUICtrlSetData($pager, $page)
GUICtrlSetData($topicer, $topic)
GUICtrlSetData($statuser, $status)
GUICtrlSetData($editstatuser, $editstatus)
GUICtrlSetData($duedater, $duedate)


EndFunc;==>Set_PageDetails


Func Set_SaveDetails()
; read the controls
    $name = GUICtrlRead($namer)
    $page = GUICtrlRead($pager)
    $topic = GUICtrlRead($topicer)
    $status = GUICtrlRead($statuser)
    $editstatus = GUICtrlRead($editstatuser)
    $duedate = GUICtrlRead($duedater)
    
;write to the ini file
    IniWrite($Location2, $item2[0], "Name", $name)
    IniWrite($Location2, $item2[0], "Page", $page)
    IniWrite($Location2, $item2[0], "Topic", $topic)
    IniWrite($Location2, $item2[0], "UserStatus", $status)
    IniWrite($Location2, $item2[0], "EditStatus", $editstatus)
    IniWrite($Location2, $item2[0], "Due", $duedate)
    
EndFunc

8)

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...