Jump to content

Problems with treeview and generating tabitems


PcExpert
 Share

Recommended Posts

<P>Hi all,<BR><BR>Its me again, with my famous code of 2459 lines:P. There's a problem which I cant solve myself. I have a treeview, and some tab items when I select an item from the tree 'gebruikers' it should give the three tabs that are already there, that works. But now I want to select a group from the tree 'groepen' I want it to destroy the previous tab using guictrlDelete(), and then create the new tab items and load some info from an ini file. <BR><BR>With this code (stripped down thing that are not needed, because the script is 2459 lines long:

#include <GUIConstants.au3>
#include <EditConstants.au3>
#Include <GuiTreeView.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#Include <GuiEdit.au3>

Local $avArray[120]
Global $CheckBox[31]
Global $newvak
Global $vakcount = 1
Global $top = 50
Global $left = 15
Global $count = 0
Global $vtotal = 1
Global $place

Opt("GUIOnEventMode", 1)

Global $IniPath1 = @ScriptDir & "\Groepen\*.ini", $IniPath2 = @ScriptDir & "\Gebruikers\*.ini"

$Gui = GUICreate("Cijfer Registratie Systeem | Hoofdscherm", 780, 430)
GUISetOnEvent($GUI_EVENT_CLOSE, "closegui_gui")
$menu_bestand = GUICtrlCreateMenu("&Bestand")
$menu_bestand_exit = GUICtrlCreateMenuItem("Afsluiten", $menu_bestand)
;GUICtrlSetOnEvent(-1, "menu")
$menu_Groepen = GUICtrlCreateMenu("&Groepen")
$menu_groepen_toevoegen = GUICtrlCreateMenuItem("Toevoegen", $menu_groepen)
;GUICtrlSetOnEvent(-1, "menu")
$menu_groepen_wijzigen = GUICtrlCreateMenuItem("Wijzigen", $menu_groepen)
;GUICtrlSetOnEvent(-1, "menu")
$menu_groepen_verwijderen = GUICtrlCreateMenuItem("Verwijderen", $menu_groepen)
;GUICtrlSetOnEvent(-1, "menu")
$menu_gebruikers = GUICtrlCreateMenu("&Gebruikers")
$menu_gebruikers_toevoegen = GUICtrlCreateMenuItem("Toevoegen", $menu_gebruikers)
;GUICtrlSetOnEvent(-1, "menu")
$menu_gebruikers_wijzigen = GUICtrlCreateMenuItem("Wijzigen", $menu_gebruikers)
;GUICtrlSetOnEvent(-1, "menu")
$menu_gebruikers_verwijderen = GUICtrlCreateMenuItem("Verwijderen", $menu_gebruikers)
;GUICtrlSetOnEvent(-1, "menu")
$menu_vakken = GUICtrlCreateMenu("&Vakken")
$menu_vakken_toevoegen = GUICtrlCreateMenuItem("Toevoegen", $menu_vakken)
;GUICtrlSetOnEvent(-1, "menu")
$menu_vakken_wijzigen = GUICtrlCreateMenuItem("Wijzigen", $menu_vakken)
;GUICtrlSetOnEvent(-1, "menu")
$menu_vakken_verwijderen = GUICtrlCreateMenuItem("Verwijderen", $menu_vakken)
;GUICtrlSetOnEvent(-1, "menu")
$menu_cijfers = GUICtrlCreateMenu("&Cijfers")
$menu_cijfers_toevoegen = GUICtrlCreateMenuItem("Toevoegen", $menu_cijfers)
;GUICtrlSetOnEvent(-1, "menu")
$menu_cijfers_wijzigen = GUICtrlCreateMenuItem("Wijzigen", $menu_cijfers)
;GUICtrlSetOnEvent(-1, "menu")
$menu_cijfers_verwijderen = GUICtrlCreateMenuItem("Verwijderen", $menu_cijfers)
;GUICtrlSetOnEvent(-1, "menu")
$menu_beoordeling = GUICtrlCreateMenu("Beoord&elingen")
$menu_beoordeling_toevoegen = GUICtrlCreateMenuItem("Toevoegen", $menu_beoordeling)
;GUICtrlSetOnEvent(-1, "menu")
$menu_beoordeling_wijzigen = GUICtrlCreateMenuItem("Wijzigen", $menu_beoordeling)
;GUICtrlSetOnEvent(-1, "menu")
$menu_beoordeling_verwijderen = GUICtrlCreateMenuItem("Verwijderen", $menu_beoordeling)
;GUICtrlSetOnEvent(-1, "menu")

$menu_docent = GUICtrlCreateMenu("&Docenten")
$menu_docent_toevoegen = GUICtrlCreateMenuItem("Toevoegen", $menu_docent)
;GUICtrlSetOnEvent(-1, "menu")
$menu_docent_wijzigen = GUICtrlCreateMenuItem("Wijzigen", $menu_docent)
;GUICtrlSetOnEvent(-1, "menu")
$menu_docent_verwijderen = GUICtrlCreateMenuItem("Verwijderen", $menu_docent)
;GUICtrlSetOnEvent(-1, "menu")

$menu_help = GUICtrlCreateMenu("&Help")
$menu_help_Help = GUICtrlCreateMenuItem("Help onderwerpen", $menu_help)
;GUICtrlSetOnEvent(-1, "menu")
$menu_help_over = GUICtrlCreateMenuItem("Info", $menu_help)
;GUICtrlSetOnEvent(-1, "menu")
$TV = GUICtrlCreateTreeView(5, 35, 120, 350)
$TVI1 = GUICtrlCreateTreeViewItem("Groepen", $TV)
GUICtrlSetColor(-1, 0x0000C0)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
TVLoadIni($TVI1, $IniPath1)
$TVI2 = GUICtrlCreateTreeViewItem("Gebruikers", $TV)
GUICtrlSetColor(-1, 0x0000C0)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
TVLoadIni($TVI2, $IniPath2)

GUISetState (@SW_SHOW, $Gui)


While 1
    Sleep(100)
Wend









Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
$treemain = StringSplit(_GUICtrlTreeView_GetTree($TV), "|")
If $treemain[1] = "Gebruikers" Then
$tab = GUICtrlCreateTab(140, 25, 630, 380)
GUICtrlCreateTabItem("Algemeen")
$Naam = GUICtrlCreateLabel("Naam:                 ", 150, 60, 300, 25)
$ovnr = GUICtrlCreateLabel("OV-Nummer:      ", 150, 80, 300, 25)
$adres = GUICtrlCreateLabel("Adres:               ", 150, 100, 300, 25)
$postcode = GUICtrlCreateLabel("Postcode:           ", 150, 120, 300, 25)
$woonplaats = GUICtrlCreateLabel("Woonplaats:       ", 150, 140, 300, 25)
$telefoonnr = GUICtrlCreateLabel("Telefoonnummer: ", 150, 160, 300, 25)
$groep = GUICtrlCreateLabel("Groep:               ", 150, 180, 300, 25)
GUICtrlSetBkColor(-1, 0xffffff)
GUICtrlCreateTabItem("Cijfers")
$vakken = GUICtrlCreateLabel("", 150, 60, 550, 25)
$toets1 = GUICtrlCreateLabel("Toets 1", 150, 90, 100, 25)
$toets2 = GUICtrlCreateLabel("Toets 2", 150, 110, 100, 25)
$toets3 = GUICtrlCreateLabel("Toets 3", 150, 130, 100, 25)
$toets4 = GUICtrlCreateLabel("Toets 4", 150, 150, 100, 25)
$rap1 = GUICtrlCreateLabel("Rapport 1", 150, 170, 100, 25)
$toets5 = GUICtrlCreateLabel("Toets 5", 150, 190, 100, 25)
$toets6 = GUICtrlCreateLabel("Toets 6", 150, 210, 100, 25)
$toets7 = GUICtrlCreateLabel("Toets 7", 150, 230, 100, 25)
$toets8 = GUICtrlCreateLabel("Toets 8", 150, 250, 100, 25)
$rap2 = GUICtrlCreateLabel("Rapport 2", 150, 270, 100, 25)
$toets9 = GUICtrlCreateLabel("Toets 9", 150, 290, 100, 25)
$toets10 = GUICtrlCreateLabel("Toets 10", 150, 310, 100, 25)
$toets11 = GUICtrlCreateLabel("Toets 11", 150, 330, 100, 25)
$toets12 = GUICtrlCreateLabel("Toets 12", 150, 350, 100, 25)
$rap3 = GUICtrlCreateLabel("Rapport 3", 150, 370, 100, 25)


$cijfer0 = GUICtrlCreateLabel("", 220, 90, 100, 25)
$cijfer1 = GUICtrlCreateLabel("", 220, 110, 100, 25)
$cijfer2 = GUICtrlCreateLabel("", 220, 130, 100, 25)
$cijfer3 = GUICtrlCreateLabel("", 220, 150, 100, 25)
$cijfer4 = GUICtrlCreateLabel("", 220, 170, 100, 25)
$cijfer5 = GUICtrlCreateLabel("", 220, 190, 100, 25)
$cijfer6 = GUICtrlCreateLabel("", 220, 210, 100, 25)
$cijfer7 = GUICtrlCreateLabel("", 220, 230, 100, 25)
$cijfer8 = GUICtrlCreateLabel("", 220, 250, 100, 25)
$cijfer9 = GUICtrlCreateLabel("", 220, 270, 100, 25)
$cijfer10 = GUICtrlCreateLabel("", 220, 290, 100, 25)
$cijfer11 = GUICtrlCreateLabel("", 220, 310, 100, 25)
$cijfer12 = GUICtrlCreateLabel("", 220, 330, 100, 25)
$cijfer13 = GUICtrlCreateLabel("", 220, 350, 100, 25)
$cijfer14 = GUICtrlCreateLabel("", 220, 370, 100, 25)

$cijfer15 = GUICtrlCreateLabel("", 270, 90, 100, 25)
$cijfer16 = GUICtrlCreateLabel("", 270, 110, 100, 25)
$cijfer17 = GUICtrlCreateLabel("", 270, 130, 100, 25)
$cijfer18 = GUICtrlCreateLabel("", 270, 150, 100, 25)
$cijfer19 = GUICtrlCreateLabel("", 270, 170, 100, 25)
$cijfer20 = GUICtrlCreateLabel("", 270, 190, 100, 25)
$cijfer21 = GUICtrlCreateLabel("", 270, 210, 100, 25)
$cijfer22 = GUICtrlCreateLabel("", 270, 230, 100, 25)
$cijfer23 = GUICtrlCreateLabel("", 270, 250, 100, 25)
$cijfer24 = GUICtrlCreateLabel("", 270, 270, 100, 25)
$cijfer25 = GUICtrlCreateLabel("", 270, 290, 100, 25)
$cijfer26 = GUICtrlCreateLabel("", 270, 310, 100, 25)
$cijfer27 = GUICtrlCreateLabel("", 270, 330, 100, 25)
$cijfer28 = GUICtrlCreateLabel("", 270, 350, 100, 25)
$cijfer29 = GUICtrlCreateLabel("", 270, 370, 100, 25)

$cijfer30 = GUICtrlCreateLabel("", 320, 90, 100, 25)
$cijfer31 = GUICtrlCreateLabel("", 320, 110, 100, 25)
$cijfer32 = GUICtrlCreateLabel("", 320, 130, 100, 25)
$cijfer33 = GUICtrlCreateLabel("", 320, 150, 100, 25)
$cijfer34 = GUICtrlCreateLabel("", 320, 170, 100, 25)
$cijfer35 = GUICtrlCreateLabel("", 320, 190, 100, 25)
$cijfer36 = GUICtrlCreateLabel("", 320, 210, 100, 25)
$cijfer37 = GUICtrlCreateLabel("", 320, 230, 100, 25)
$cijfer38 = GUICtrlCreateLabel("", 320, 250, 100, 25)
$cijfer39 = GUICtrlCreateLabel("", 320, 270, 100, 25)
$cijfer40 = GUICtrlCreateLabel("", 320, 290, 100, 25)
$cijfer41 = GUICtrlCreateLabel("", 320, 310, 100, 25)
$cijfer42 = GUICtrlCreateLabel("", 320, 330, 100, 25)
$cijfer43 = GUICtrlCreateLabel("", 320, 350, 100, 25)
$cijfer44 = GUICtrlCreateLabel("", 320, 370, 100, 25)

$cijfer45 = GUICtrlCreateLabel("", 370, 90, 100, 25)
$cijfer46 = GUICtrlCreateLabel("", 370, 110, 100, 25)
$cijfer47 = GUICtrlCreateLabel("", 370, 130, 100, 25)
$cijfer48 = GUICtrlCreateLabel("", 370, 150, 100, 25)
$cijfer49 = GUICtrlCreateLabel("", 370, 170, 100, 25)
$cijfer50 = GUICtrlCreateLabel("", 370, 190, 100, 25)
$cijfer51 = GUICtrlCreateLabel("", 370, 210, 100, 25)
$cijfer52 = GUICtrlCreateLabel("", 370, 230, 100, 25)
$cijfer53 = GUICtrlCreateLabel("", 370, 250, 100, 25)
$cijfer54 = GUICtrlCreateLabel("", 370, 270, 100, 25)
$cijfer55 = GUICtrlCreateLabel("", 370, 290, 100, 25)
$cijfer56 = GUICtrlCreateLabel("", 370, 310, 100, 25)
$cijfer57 = GUICtrlCreateLabel("", 370, 330, 100, 25)
$cijfer58 = GUICtrlCreateLabel("", 370, 350, 100, 25)
$cijfer59 = GUICtrlCreateLabel("", 370, 370, 100, 25)

$cijfer60 = GUICtrlCreateLabel("", 420, 90, 100, 25)
$cijfer61 = GUICtrlCreateLabel("", 420, 110, 100, 25)
$cijfer62 = GUICtrlCreateLabel("", 420, 130, 100, 25)
$cijfer63 = GUICtrlCreateLabel("", 420, 150, 100, 25)
$cijfer64 = GUICtrlCreateLabel("", 420, 170, 100, 25)
$cijfer65 = GUICtrlCreateLabel("", 420, 190, 100, 25)
$cijfer66 = GUICtrlCreateLabel("", 420, 210, 100, 25)
$cijfer67 = GUICtrlCreateLabel("", 420, 230, 100, 25)
$cijfer68 = GUICtrlCreateLabel("", 420, 250, 100, 25)
$cijfer69 = GUICtrlCreateLabel("", 420, 270, 100, 25)
$cijfer70 = GUICtrlCreateLabel("", 420, 290, 100, 25)
$cijfer71 = GUICtrlCreateLabel("", 420, 310, 100, 25)
$cijfer72 = GUICtrlCreateLabel("", 420, 330, 100, 25)
$cijfer73 = GUICtrlCreateLabel("", 420, 350, 100, 25)
$cijfer74 = GUICtrlCreateLabel("", 420, 370, 100, 25)

$cijfer75 = GUICtrlCreateLabel("", 470, 90, 100, 25)
$cijfer76 = GUICtrlCreateLabel("", 470, 110, 100, 25)
$cijfer77 = GUICtrlCreateLabel("", 470, 130, 100, 25)
$cijfer78 = GUICtrlCreateLabel("", 470, 150, 100, 25)
$cijfer79 = GUICtrlCreateLabel("", 470, 170, 100, 25)
$cijfer80 = GUICtrlCreateLabel("", 470, 190, 100, 25)
$cijfer81 = GUICtrlCreateLabel("", 470, 210, 100, 25)
$cijfer82 = GUICtrlCreateLabel("", 470, 230, 100, 25)
$cijfer83 = GUICtrlCreateLabel("", 470, 250, 100, 25)
$cijfer84 = GUICtrlCreateLabel("", 470, 270, 100, 25)
$cijfer85 = GUICtrlCreateLabel("", 470, 290, 100, 25)
$cijfer86 = GUICtrlCreateLabel("", 470, 310, 100, 25)
$cijfer87 = GUICtrlCreateLabel("", 470, 330, 100, 25)
$cijfer88 = GUICtrlCreateLabel("", 470, 350, 100, 25)
$cijfer89 = GUICtrlCreateLabel("", 470, 370, 100, 25)

$cijfer90 = GUICtrlCreateLabel("", 520, 90, 100, 25)
$cijfer91 = GUICtrlCreateLabel("", 520, 110, 100, 25)
$cijfer92 = GUICtrlCreateLabel("", 520, 130, 100, 25)
$cijfer93 = GUICtrlCreateLabel("", 520, 150, 100, 25)
$cijfer94 = GUICtrlCreateLabel("", 520, 170, 100, 25)
$cijfer95 = GUICtrlCreateLabel("", 520, 190, 100, 25)
$cijfer96 = GUICtrlCreateLabel("", 520, 210, 100, 25)
$cijfer97 = GUICtrlCreateLabel("", 520, 230, 100, 25)
$cijfer98 = GUICtrlCreateLabel("", 520, 250, 100, 25)
$cijfer99 = GUICtrlCreateLabel("", 520, 270, 100, 25)
$cijfer100 = GUICtrlCreateLabel("", 520, 290, 100, 25)
$cijfer101 = GUICtrlCreateLabel("", 520, 310, 100, 25)
$cijfer102 = GUICtrlCreateLabel("", 520, 330, 100, 25)
$cijfer103 = GUICtrlCreateLabel("", 520, 350, 100, 25)
$cijfer104 = GUICtrlCreateLabel("", 520, 370, 100, 25)

$cijfer105 = GUICtrlCreateLabel("", 570, 90, 100, 25)
$cijfer106 = GUICtrlCreateLabel("", 570, 110, 100, 25)
$cijfer107 = GUICtrlCreateLabel("", 570, 130, 100, 25)
$cijfer108 = GUICtrlCreateLabel("", 570, 150, 100, 25)
$cijfer109 = GUICtrlCreateLabel("", 570, 170, 100, 25)
$cijfer110 = GUICtrlCreateLabel("", 570, 190, 100, 25)
$cijfer111 = GUICtrlCreateLabel("", 570, 210, 100, 25)
$cijfer112 = GUICtrlCreateLabel("", 570, 230, 100, 25)
$cijfer113 = GUICtrlCreateLabel("", 570, 250, 100, 25)
$cijfer114 = GUICtrlCreateLabel("", 570, 270, 100, 25)
$cijfer115 = GUICtrlCreateLabel("", 570, 290, 100, 25)
$cijfer116 = GUICtrlCreateLabel("", 570, 310, 100, 25)
$cijfer117 = GUICtrlCreateLabel("", 570, 330, 100, 25)
$cijfer118 = GUICtrlCreateLabel("", 570, 350, 100, 25)
$cijfer119 = GUICtrlCreateLabel("", 570, 370, 100, 25)

$cijfer120 = GUICtrlCreateLabel("", 620, 90, 100, 25)
$cijfer121 = GUICtrlCreateLabel("", 620, 110, 100, 25)
$cijfer122 = GUICtrlCreateLabel("", 620, 130, 100, 25)
$cijfer123 = GUICtrlCreateLabel("", 620, 150, 100, 25)
$cijfer124 = GUICtrlCreateLabel("", 620, 170, 100, 25)
$cijfer125 = GUICtrlCreateLabel("", 620, 190, 100, 25)
$cijfer126 = GUICtrlCreateLabel("", 620, 210, 100, 25)
$cijfer127 = GUICtrlCreateLabel("", 620, 230, 100, 25)
$cijfer128 = GUICtrlCreateLabel("", 620, 250, 100, 25)
$cijfer129 = GUICtrlCreateLabel("", 620, 270, 100, 25)
$cijfer130 = GUICtrlCreateLabel("", 620, 290, 100, 25)
$cijfer131 = GUICtrlCreateLabel("", 620, 310, 100, 25)
$cijfer132 = GUICtrlCreateLabel("", 620, 330, 100, 25)
$cijfer133 = GUICtrlCreateLabel("", 620, 350, 100, 25)
$cijfer134 = GUICtrlCreateLabel("", 620, 370, 100, 25)

$cijfer135 = GUICtrlCreateLabel("", 670, 90, 100, 25)
$cijfer136 = GUICtrlCreateLabel("", 670, 110, 100, 25)
$cijfer137 = GUICtrlCreateLabel("", 670, 130, 100, 25)
$cijfer138 = GUICtrlCreateLabel("", 670, 150, 100, 25)
$cijfer139 = GUICtrlCreateLabel("", 670, 170, 100, 25)
$cijfer140 = GUICtrlCreateLabel("", 670, 190, 100, 25)
$cijfer141 = GUICtrlCreateLabel("", 670, 210, 100, 25)
$cijfer142 = GUICtrlCreateLabel("", 670, 230, 100, 25)
$cijfer143 = GUICtrlCreateLabel("", 670, 250, 100, 25)
$cijfer144 = GUICtrlCreateLabel("", 670, 270, 100, 25)
$cijfer145 = GUICtrlCreateLabel("", 670, 290, 100, 25)
$cijfer146 = GUICtrlCreateLabel("", 670, 310, 100, 25)
$cijfer147 = GUICtrlCreateLabel("", 670, 330, 100, 25)
$cijfer148 = GUICtrlCreateLabel("", 670, 350, 100, 25)
$cijfer149 = GUICtrlCreateLabel("", 670, 370, 100, 25)




GUICtrlCreateTabItem("Beoordelingen")
$beoordeling = GUICtrlCreateEdit("", 150, 60, 605, 330, $ES_READONLY + $ES_WANTRETURN + + $WS_VSCROLL)
_GUICtrlEdit_SetMargins($beoordeling, $EC_RIGHTMARGIN, 0, 10) 
   $rnaam = IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Algemeen", "naam", "")
   $rov = IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Algemeen", "OV", "")
   $radres = IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Algemeen", "adres", "")
   $rpostcode = IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Algemeen", "postcode", "")
   $rwoonplaats = IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Algemeen", "woonplaats", "")
   $rtelefoon = IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Algemeen", "telefoon", "")
   $rgroep = IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Algemeen", "groep", "")
   $rvakken = IniRead(@ScriptDir & "\groepen\" & $rgroep & ".ini", "Algemeen", "vakken", "")
   $rbeoordeling = IniReadSection(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "beoordeling")
   $rvakken1 = StringReplace($rvakken, ",", "        ")
   $avakken = StringSplit($rvakken, ",")
   If 1 < UBound($avakken)-1 Then
   $avakken1 = $avakken[1]
   Else
$avakken1 = ""   
   EndIf
   If 2 < UBound($avakken)-1 Then
   $avakken2 = $avakken[2]
   Else
$avakken2 = ""   
   EndIf
   If 3 < UBound($avakken)-1 Then
   $avakken3 = $avakken[3]
   Else
$avakken3 = ""   
   EndIf
   If 4 < UBound($avakken)-1 Then
   $avakken4 = $avakken[4]
   Else
$avakken4 = ""   
   EndIf
   If 5 < UBound($avakken)-1 Then
   $avakken5 = $avakken[5]
   Else
   $avakken5 = ""
   EndIf
   If 6 < UBound($avakken)-1 Then
   $avakken6 = $avakken[6]
   Else
   $avakken6 = ""
   EndIf
   If 7 < UBound($avakken)-1 Then
   $avakken7 = $avakken[7]
   Else
   $avakken7 = ""
   EndIf
   If 8 < UBound($avakken)-1 Then
   $avakken8 = $avakken[8]
   Else
   $avakken8 = ""
   EndIf
   If 9 < UBound($avakken)-1 Then
   $avakken9 = $avakken[9]
   Else
   $avakken9 = ""
   EndIf
   If 10 < UBound($avakken)-1 Then
   $avakken10 = $avakken[10]
   Else
   $avakken10 = ""
   EndIf
         If Not @error Then 
   GUICtrlSetData($Naam, "Naam:               " & $rnaam)
   GUICtrlSetData($ovnr, "OV-Nummer:        " & $rov)
   GUICtrlSetData($adres, "Adres:                 " & $radres)
   GUICtrlSetData($postcode, "Postcode:         " & $rpostcode)
   GUICtrlSetData($woonplaats, "Woonplaats:     " & $rwoonplaats)
   GUICtrlSetData($telefoonnr, "Telefoonnummer: " & $rtelefoon)
   GUICtrlSetData($groep, "Groep:                 " & $rgroep)
   GUICtrlSetData($vakken, "                       " & $rvakken1)
   If IsArray($rbeoordeling) Then
   _GUICtrlEdit_SetText($beoordeling, "")   
   For $i = 1 To $rbeoordeling[0][0]
   _GUICtrlEdit_AppendText($beoordeling, $rbeoordeling[$i][0] & ":" & @CRLF & $rbeoordeling[$i][1] & @CRLF & @CRLF)
   Next
   EndIf
   If $avakken1 = Not "" Then
   $avk1 = StringSplit(IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Cijfers", $avakken1, ""), ",")
   GUICtrlSetData($cijfer0, $avk1[1])
   GUICtrlSetData($cijfer1, $avk1[2])
   GUICtrlSetData($cijfer2, $avk1[3])
   GUICtrlSetData($cijfer3, $avk1[4])
   GUICtrlSetData($cijfer4, $avk1[5])
   GUICtrlSetData($cijfer5, $avk1[6])
   GUICtrlSetData($cijfer6, $avk1[7])
   GUICtrlSetData($cijfer7, $avk1[8])
   GUICtrlSetData($cijfer8, $avk1[9])
   GUICtrlSetData($cijfer9, $avk1[10])
   GUICtrlSetData($cijfer10, $avk1[11])
   GUICtrlSetData($cijfer11, $avk1[12])
   GUICtrlSetData($cijfer12, $avk1[13])
   GUICtrlSetData($cijfer13, $avk1[14])
   GUICtrlSetData($cijfer14, $avk1[15])
   EndIf
   If $avakken2 = Not "" Then
   $avk2 = StringSplit(IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Cijfers", $avakken2, ""), ",")
   GUICtrlSetData($cijfer15, $avk2[1])
   GUICtrlSetData($cijfer16, $avk2[2])
   GUICtrlSetData($cijfer17, $avk2[3])
   GUICtrlSetData($cijfer18, $avk2[4])
   GUICtrlSetData($cijfer19, $avk2[5])
   GUICtrlSetData($cijfer20, $avk2[6])
   GUICtrlSetData($cijfer21, $avk2[7])
   GUICtrlSetData($cijfer22, $avk2[8])
   GUICtrlSetData($cijfer23, $avk2[9])
   GUICtrlSetData($cijfer24, $avk2[10])
   GUICtrlSetData($cijfer25, $avk2[11])
   GUICtrlSetData($cijfer26, $avk2[12])
   GUICtrlSetData($cijfer27, $avk2[13])
   GUICtrlSetData($cijfer28, $avk2[14])
   GUICtrlSetData($cijfer29, $avk2[15])
   EndIf
   If $avakken3 = Not "" Then
   $avk3 = StringSplit(IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Cijfers", $avakken3, ""), ",")
   GUICtrlSetData($cijfer30, $avk3[1])
   GUICtrlSetData($cijfer31, $avk3[2])
   GUICtrlSetData($cijfer32, $avk3[3])
   GUICtrlSetData($cijfer33, $avk3[4])
   GUICtrlSetData($cijfer34, $avk3[5])
   GUICtrlSetData($cijfer35, $avk3[6])
   GUICtrlSetData($cijfer36, $avk3[7])
   GUICtrlSetData($cijfer37, $avk3[8])
   GUICtrlSetData($cijfer38, $avk3[9])
   GUICtrlSetData($cijfer39, $avk3[10])
   GUICtrlSetData($cijfer40, $avk3[11])
   GUICtrlSetData($cijfer41, $avk3[12])
   GUICtrlSetData($cijfer42, $avk3[13])
   GUICtrlSetData($cijfer43, $avk3[14])
   GUICtrlSetData($cijfer44, $avk3[15])
   EndIf
   If $avakken4 = Not "" Then
   $avk4 = StringSplit(IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Cijfers", $avakken4, ""), ",")
   GUICtrlSetData($cijfer45, $avk4[1])
   GUICtrlSetData($cijfer46, $avk4[2])
   GUICtrlSetData($cijfer47, $avk4[3])
   GUICtrlSetData($cijfer48, $avk4[4])
   GUICtrlSetData($cijfer49, $avk4[5])
   GUICtrlSetData($cijfer50, $avk4[6])
   GUICtrlSetData($cijfer51, $avk4[7])
   GUICtrlSetData($cijfer52, $avk4[8])
   GUICtrlSetData($cijfer53, $avk4[9])
   GUICtrlSetData($cijfer54, $avk4[10])
   GUICtrlSetData($cijfer55, $avk4[11])
   GUICtrlSetData($cijfer56, $avk4[12])
   GUICtrlSetData($cijfer57, $avk4[13])
   GUICtrlSetData($cijfer58, $avk4[14])
   GUICtrlSetData($cijfer59, $avk4[15])
   EndIf
   If $avakken5 = Not "" Then
   $avk5 = StringSplit(IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Cijfers", $avakken5, ""), ",")
   GUICtrlSetData($cijfer60, $avk5[1])
   GUICtrlSetData($cijfer61, $avk5[2])
   GUICtrlSetData($cijfer62, $avk5[3])
   GUICtrlSetData($cijfer63, $avk5[4])
   GUICtrlSetData($cijfer64, $avk5[5])
   GUICtrlSetData($cijfer65, $avk5[6])
   GUICtrlSetData($cijfer66, $avk5[7])
   GUICtrlSetData($cijfer67, $avk5[8])
   GUICtrlSetData($cijfer68, $avk5[9])
   GUICtrlSetData($cijfer69, $avk5[10])
   GUICtrlSetData($cijfer70, $avk5[11])
   GUICtrlSetData($cijfer71, $avk5[12])
   GUICtrlSetData($cijfer72, $avk5[13])
   GUICtrlSetData($cijfer73, $avk5[14])
   GUICtrlSetData($cijfer74, $avk5[15])
   EndIf
   If $avakken6 = Not "" Then
   $avk6 = StringSplit(IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Cijfers", $avakken6, ""), ",")
   GUICtrlSetData($cijfer75, $avk6[1])
   GUICtrlSetData($cijfer76, $avk6[2])
   GUICtrlSetData($cijfer77, $avk6[3])
   GUICtrlSetData($cijfer78, $avk6[4])
   GUICtrlSetData($cijfer79, $avk6[5])
   GUICtrlSetData($cijfer80, $avk6[6])
   GUICtrlSetData($cijfer81, $avk6[7])
   GUICtrlSetData($cijfer82, $avk6[8])
   GUICtrlSetData($cijfer83, $avk6[9])
   GUICtrlSetData($cijfer84, $avk6[10])
   GUICtrlSetData($cijfer85, $avk6[11])
   GUICtrlSetData($cijfer86, $avk6[12])
   GUICtrlSetData($cijfer87, $avk6[13])
   GUICtrlSetData($cijfer88, $avk6[14])
   GUICtrlSetData($cijfer89, $avk6[15])
   EndIf
   If $avakken7 = Not "" Then
   $avk7 = StringSplit(IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Cijfers", $avakken7, ""), ",")
   GUICtrlSetData($cijfer90, $avk7[1])
   GUICtrlSetData($cijfer91, $avk7[2])
   GUICtrlSetData($cijfer92, $avk7[3])
   GUICtrlSetData($cijfer93, $avk7[4])
   GUICtrlSetData($cijfer94, $avk7[5])
   GUICtrlSetData($cijfer95, $avk7[6])
   GUICtrlSetData($cijfer96, $avk7[7])
   GUICtrlSetData($cijfer97, $avk7[8])
   GUICtrlSetData($cijfer98, $avk7[9])
   GUICtrlSetData($cijfer99, $avk7[10])
   GUICtrlSetData($cijfer100, $avk7[11])
   GUICtrlSetData($cijfer101, $avk7[12])
   GUICtrlSetData($cijfer102, $avk7[13])
   GUICtrlSetData($cijfer103, $avk7[14])
   GUICtrlSetData($cijfer104, $avk7[15])
   EndIf
   If $avakken8 = Not "" Then   
   $avk8 = StringSplit(IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Cijfers", $avakken8, ""), ",")
   GUICtrlSetData($cijfer105, $avk8[1])
   GUICtrlSetData($cijfer106, $avk8[2])
   GUICtrlSetData($cijfer107, $avk8[3])
   GUICtrlSetData($cijfer108, $avk8[4])
   GUICtrlSetData($cijfer109, $avk8[5])
   GUICtrlSetData($cijfer110, $avk8[6])
   GUICtrlSetData($cijfer111, $avk8[7])
   GUICtrlSetData($cijfer112, $avk8[8])
   GUICtrlSetData($cijfer113, $avk8[9])
   GUICtrlSetData($cijfer114, $avk8[10])
   GUICtrlSetData($cijfer115, $avk8[11])
   GUICtrlSetData($cijfer116, $avk8[12])
   GUICtrlSetData($cijfer117, $avk8[13])
   GUICtrlSetData($cijfer118, $avk8[14])
   GUICtrlSetData($cijfer119, $avk8[15])
   EndIf
   if $avakken9 = Not "" Then
   $avk9 = StringSplit(IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Cijfers", $avakken9, ""), ",")
   GUICtrlSetData($cijfer120, $avk9[1])
   GUICtrlSetData($cijfer121, $avk9[2])
   GUICtrlSetData($cijfer122, $avk9[3])
   GUICtrlSetData($cijfer123, $avk9[4])
   GUICtrlSetData($cijfer124, $avk9[5])
   GUICtrlSetData($cijfer125, $avk9[6])
   GUICtrlSetData($cijfer126, $avk9[7])
   GUICtrlSetData($cijfer127, $avk9[8])
   GUICtrlSetData($cijfer128, $avk9[9])
   GUICtrlSetData($cijfer129, $avk9[10])
   GUICtrlSetData($cijfer130, $avk9[11])
   GUICtrlSetData($cijfer131, $avk9[12])
   GUICtrlSetData($cijfer132, $avk9[13])
   GUICtrlSetData($cijfer133, $avk9[14])
   GUICtrlSetData($cijfer134, $avk9[15])
   EndIf
   If $avakken10 = Not "" Then
   $avk10 = StringSplit(IniRead(@ScriptDir & "\" & _TVGetItemTree($TV, "\") & ".ini", "Cijfers", $avakken10, ""), ",")
   GUICtrlSetData($cijfer135, $avk10[1])
   GUICtrlSetData($cijfer136, $avk10[2])
   GUICtrlSetData($cijfer137, $avk10[3])
   GUICtrlSetData($cijfer138, $avk10[4])
   GUICtrlSetData($cijfer139, $avk10[5])
   GUICtrlSetData($cijfer140, $avk10[6])
   GUICtrlSetData($cijfer141, $avk10[7])
   GUICtrlSetData($cijfer142, $avk10[8])
   GUICtrlSetData($cijfer143, $avk10[9])
   GUICtrlSetData($cijfer144, $avk10[10])
   GUICtrlSetData($cijfer145, $avk10[11])
   GUICtrlSetData($cijfer146, $avk10[12])
   GUICtrlSetData($cijfer147, $avk10[13])
   GUICtrlSetData($cijfer148, $avk10[14])
   GUICtrlSetData($cijfer149, $avk10[15])   
   EndIf
  EndIf 
Else  
;MsgBox(0, "", "") 
   GUICtrlDelete($tab)       
   $tab2 = GUICtrlCreateTab(140, 25, 630, 380)
GUICtrlCreateTabItem("Algemeen")
EndIf   
    EndSwitch
EndFunc

Func TVLoadIni($tviID, $iPath)
    Local $FFFF, $FFNF, $STR
    $FFFF = FileFindFirstFile($iPath)
    If $FFFF = -1 Then Return -1
    While 1
        $FFNF = FileFindNextFile($FFFF)
        If @error Then ExitLoop
        $STR = StringTrimRight($FFNF, 4)
        GUICtrlCreateTreeViewItem($STR, $tviID)
        GUICtrlSetOnEvent(-1, "Event")
        GUICtrlSetColor(-1, 0x0000C0)
    WEnd
    FileClose($FFFF)
    Return 0
EndFunc

Func _TVGetItemTree($i_treeview, $s_sep_char, $h_tv_item = 0)
    Local $szPath = "", $hParent, $h_item
    If $h_tv_item <> 0 Then
        $h_item = $h_tv_item
    Else
        $h_item = GUICtrlSendMsg($i_treeview, $TVM_GETNEXTITEM, $TVGN_CARET, 0)
    EndIf
    If $h_item > 0 Then
        $szPath = _TVGetItemText($i_treeview, $h_item)
        Do
            $hParent = GUICtrlSendMsg($i_treeview, $TVM_GETNEXTITEM, $TVGN_PARENT, $h_item)
            If $hParent > 0 Then $szPath = _TVGetItemText($i_treeview, $hParent) & $s_sep_char & $szPath
            $h_item = $hParent
        Until $h_item <= 0
    EndIf

    Return $szPath
EndFunc;==>_TVGetItemTree

Func _TVGetItemText($i_treeview, $h_item = 0); copy, name changed
    Local $s_txt = ""
    If $h_item = 0 Then Return ""
    Local $st_txt = DllStructCreate("char[4096]")
    Local $st_TVI = DllStructCreate("uint;uint;uint;uint;ptr;int;int;int;int;uint;int")
    DllStructSetData($st_TVI, 1, $TVIF_TEXT)
    DllStructSetData($st_TVI, 2, $h_item)
    DllStructSetData($st_TVI, 5, DllStructGetPtr($st_txt))
    DllStructSetData($st_TVI, 6, DllStructGetSize($st_txt))
    If GUICtrlSendMsg($i_treeview, $TVM_GETITEM, 0, DllStructGetPtr($st_TVI)) Then $s_txt = DllStructGetData($st_txt, 1)
    Return $s_txt
EndFunc;==>_TVGetText
Func Closegui_gui()
   Exit
EndFunc

It creates the right tab items when I click an Item under 'gebruikers' but it gives me an error when I try to clixk an item under 'groepen' I get an error about my guictrldelete() statement but why, I dont know.

Thanks for helping me out.

P.S.

As you might me able to see, my post is messed up, I think that that is because of the autoit tags I used, I have replace them now by code tags.

Edited by PcExpert
Link to comment
Share on other sites

ahum, I just saw I posted in the wrong section, could someone please move it to General help and support? Thank you

Actually you posted this in chat and I moved it here.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I've added the guictrlcreatetabItem(""), but it didnt solve the problem.

A groepen\[grouphere].ini file looks like this:

[algemeen]
vakken=GRA,DAS,NED,VBM,GHS,PLF,TRD,WDS,GTS,
docenten=M. yname,Y. ourname,H. ername,B. oot,G. Ame,C. lock

A gebruikers\[usernamehere].ini file looks like this:

[Algemeen]
naam=MY NAME
adres=MY ADDRESS
postcode=MY POSTALCODE
woonplaats=MY CITY
telefoon=MY PHONENUMBER
email=MYEMAIL
ov=MY SCHOOLNUMBER
groep=MYGROUP
[Cijfers]
GRA=,,,,,,,,,,,,,,
DAS=,,,,,,,,,,,,,,
NED=,,,,,,,,,,,,,,
ENG=,,,,,,,,,,,,,,
VBM=,,,,,,,,,,,,,,
GHS=,,,,,,,,,,,,,,
PLF=,,,,,,,,,,,,,,
TRD=,,,,,,,,,,,,,,
WDS=,,,,,,,,,,,,,,
GTS=,,,,,,,,,,,,,,
[Beoordeling]

I cannot make the example smaller, because the example would be useless then.

Edited by PcExpert
Link to comment
Share on other sites

  • 2 weeks later...
  • Moderators

PcExpert,

I think this very cut down version of your code does what you want:

#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <GuiEdit.au3>

Local $avArray[120], $CheckBox[31]
Global $newvak, $vakcount = 1, $vtotal = 1
Global $top = 50, $left = 15, $count = 0, $place
Global $tab_geb = 9999, $tab_gro = 9999   ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Opt("GUIOnEventMode", 1)

Global $IniPath1 = @ScriptDir & "\Groepen\*.ini", $IniPath2 = @ScriptDir & "\Gebruikers\*.ini"

$Gui = GUICreate("Cijfer Registratie Systeem | Hoofdscherm", 780, 430)
GUISetOnEvent($GUI_EVENT_CLOSE, "closegui_gui")

$TV = GUICtrlCreateTreeView(5, 35, 120, 350)
$TVI1 = GUICtrlCreateTreeViewItem("Groepen", $TV)
GUICtrlSetColor(-1, 0x0000C0)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
TVLoadIni($TVI1, $IniPath1)
$TVI2 = GUICtrlCreateTreeViewItem("Gebruikers", $TV)
GUICtrlSetColor(-1, 0x0000C0)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
TVLoadIni($TVI2, $IniPath2)

GUISetState(@SW_SHOW, $Gui)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            $treemain = StringSplit(_GUICtrlTreeView_GetTree($TV), "|")
            If $treemain[1] = "Gebruikers" Then
                GUICtrlDelete($tab_gro) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                $tab_gro = 9999      ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                $tab_geb = GUICtrlCreateTab(140, 25, 630, 380)
                GUICtrlCreateTabItem("Algemeen")
                GUICtrlCreateTabItem("Cijfers")
                GUICtrlCreateTabItem("Beoordelingen")
                GuiCtrlcreateTabitem("") 
            Else
                GUICtrlDelete($tab_geb) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                $tab_geb = 9999      ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                $tab_gro = GUICtrlCreateTab(140, 25, 630, 380)
                GUICtrlCreateTabItem("Algemeen_gro")
                GUICtrlCreateTabItem("Cijfers_gro")
                GUICtrlCreateTabItem("Beoordelingen_gro")
                GuiCtrlcreateTabitem("")
            EndIf
    EndSwitch
EndFunc  ;==>Event

Func TVLoadIni($tviID, $iPath)
    Local $FFFF, $FFNF, $STR
    $FFFF = FileFindFirstFile($iPath)
    If $FFFF = -1 Then Return -1
    While 1
        $FFNF = FileFindNextFile($FFFF)
        If @error Then ExitLoop
        $STR = StringTrimRight($FFNF, 4)
        GUICtrlCreateTreeViewItem($STR, $tviID)
        GUICtrlSetOnEvent(-1, "Event")
        GUICtrlSetColor(-1, 0x0000C0)
    WEnd
    FileClose($FFFF)
    Return 0
EndFunc  ;==>TVLoadIni

Func _TVGetItemTree($i_treeview, $s_sep_char, $h_tv_item = 0)
    Local $szPath = "", $hParent, $h_item
    If $h_tv_item <> 0 Then
        $h_item = $h_tv_item
    Else
        $h_item = GUICtrlSendMsg($i_treeview, $TVM_GETNEXTITEM, $TVGN_CARET, 0)
    EndIf
    If $h_item > 0 Then
        $szPath = _TVGetItemText($i_treeview, $h_item)
        Do
            $hParent = GUICtrlSendMsg($i_treeview, $TVM_GETNEXTITEM, $TVGN_PARENT, $h_item)
            If $hParent > 0 Then $szPath = _TVGetItemText($i_treeview, $hParent) & $s_sep_char & $szPath
            $h_item = $hParent
        Until $h_item <= 0
    EndIf

    Return $szPath
EndFunc  ;==>_TVGetItemTree

Func _TVGetItemText($i_treeview, $h_item = 0); copy, name changed
    Local $s_txt = ""
    If $h_item = 0 Then Return ""
    Local $st_txt = DllStructCreate("char[4096]")
    Local $st_TVI = DllStructCreate("uint;uint;uint;uint;ptr;int;int;int;int;uint;int")
    DllStructSetData($st_TVI, 1, $TVIF_TEXT)
    DllStructSetData($st_TVI, 2, $h_item)
    DllStructSetData($st_TVI, 5, DllStructGetPtr($st_txt))
    DllStructSetData($st_TVI, 6, DllStructGetSize($st_txt))
    If GUICtrlSendMsg($i_treeview, $TVM_GETITEM, 0, DllStructGetPtr($st_TVI)) Then $s_txt = DllStructGetData($st_txt, 1)
    Return $s_txt
EndFunc  ;==>_TVGetItemText
Func Closegui_gui()
    Exit
EndFunc  ;==>Closegui_gui

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

PcExpert,

You are welcome. It made me learn a bit about treeviews as well. ;-)

If I might make a suggestion - try and cut down on the size of the scripts you post when you need assistance. As you saw on earlier this thread, a lot of people will not look at very long scripts. Try to reduce them to the minimum needed to indicate the problem - much as I did when replying. It also helps if you use codebox tags rather then just code - viewers do not then get immediately frightened by the sheer number of lines!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hmm, I was just trying to implement it into the complete script so I first added all the functions (I ofcourse got alot of errors because the other gui's are not there yet, but I continued anyway) So the script started fine after ignoring the errors. I clicked on my treeitems to see if it worked, and it worked!:P

Now I, ofcourse, wanted to add my other gui's, so I just copied and pasted the gui's code, but once all gui's were in (without erros now ofcourse) I ran my script, but now the treeview did not respond to an event anymore, so there also were no tab items and all the other things that should be there, but they were there before I put in all the gui's.

What's happening?

edit:

Thanks for your tips, I will do that next time I post some code;).

Edited by PcExpert
Link to comment
Share on other sites

  • Moderators

What's happening?

How am I supposed to know without the code? ;-)

Upload your whole script (so as not to frighten anyone) and I will take a look.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

PcExpert,

You have a lot of different GUIs in your script at the same time - albeit most are hidden until needed. Autoit assumes the last GUI created is the active one and so creates controls there. In your case, the last GUI you created was $gui_info, so AutoIt thinks that is the active GUI. Autoit cannot read your mind, you must tell it what to do.

You need to read about GUISwitch in the Help file. It allows you to inform AutoIt of the currently active GUI - and then it knows where to create controls.

So in the specific case of the tabs I sorted last time, you need to add GUISwitch($Gui) at the very beginning of Func Event() - then Autoit creates the tabs where you want it to.

As I have not looked in detail at the script I cannot say for sure, but there may well be other occasions where you will need to use GUISwitch - basically every time you show another GUI and want to create a control within it.

I would also recommend looking at #Region...#EndRegion. Your code is longish and it would be helpful to break it out into regions which you can shrink when they are not needed. Try this short snippet in SciTE:

#Region
; You can see me!
#EndRegion
#Region
; And me!
#EndRegion

By clicking on the [-] next to the #Region's you can hide or show the contents of the region. You can also use the 'View - Toggle all folds' menu item to do this en masse. It will help make the long code more manageable - but do label the regions or you will not know what is hidden where!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hmm everything seems to work OK now, accept one thing:

Once all information is loaded from the ini to the labels, I need to click the current tabitem to show to new data. Is there a way to reaload it automatically? I looked at the setfocus functions (because that is what you do actually) but that did not seem to work. Any ideas?

Link to comment
Share on other sites

  • Moderators

PcExpert,

Glad it works. I have been all over the script you posted and I have few remarks:

1. You need to comment your code. I know you know how it works now, but give it a few months and you will find it incomprehensible unless you put in comments so you can find your way around. many of your variables and arrays have very similar names - not necessarily a bad thing IF you make sure you can remember which is which and what it does. I often get told I overcomment my code - I would prefer to do that than have to scratch around recreating the whole script just because I cannot work out what I was doing at that point.

2. You need to learn about and use loops a lot more. Some of your code is really painful to look at. ;-) Look at the attached version of your script tha I have worked on. I do not guarantee it works perfectly (because I do not entirely follow your code given that the few words that might help are in Dutch!) but it does not crash and should give you an idea of how you can use loops to drastically shorten your code (my version is about 1500 lines versus 2500 in yours). I have also created another function at the end to replace the same code which existed in at least 3 places. Your code was not wrong, but it was long-winded and a bit clumsy at times. This is something you learn as you go along, if you take the trouble to look at other code and see where it has done something neatly. I learn something from these forums everyday - as I am sure do many others. No-one has a monopoly of good coding - but you should try to produce elegant, concise code every time.

3. Try to format your code in a standard style. I have done some of this (particularly in the GUI creation region, and specifically in the menu creation part) to try and show you how much easier it is to read and understand. Again, there is nothing wrong with your code as it was, but formatting it makes it look better - you can find things more easily, errors are sometimes easier to spot, it helps others (like me!) when they try to work out what is going on! If you can get into a good formatting habit now, it will serve you well - trust me on this.

4. I have used the #Region...#EndRegion statements I mentioned earlier to divide the code into smaller chunks - I hope you agree it makes the whole thing easier to manage.

Please do not take these remarks the wrong way - you have done a good job so far and should take them as contructive criticism to help you do better. Good luck with the rest of the project.

M23

P.S. I shall expect to see an "assist" in the Info box next time round - or no more help!! :-)

Edit: Our posts crossed - if you want some help on the tab load problem, please post or upload some working .ini files that show the problem.

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Melba, ofcourse I will add you to the special thanks section. I also found out that you added a for next loop instead of creating 100+ labels, that is so nice to see:). I am very happy with your help. I'll now continue working on the script to see if it works fine now. Again, thanks for all the help you provided:).

Link to comment
Share on other sites

My current code will, once you clicked on a user under 'gebruikers', update the information on all the tabs. But since the tab 'algemeen' is the default, it wont update the info on it automatically. To do so, I first have to switch to another tab and then switch back to the tab 'algemeen', and then the new information is there. But is there a way to automatically show the new data, without having to switch to other tabs to view the information?

The code I tested with is in the attachment.

The inifile 'gebruikers\56732.ini':

[Algemeen]
naam=MYNAME
adres=MYADDRESS
postcode=MYPOSTALCODE
woonplaats=MYCITY
telefoon=MYPHONENUMBER
email=MYEMAIL
ov=NYNUMBER
groep=MYGROUP
[Cijfers]
ISW=,,,,,,,,,,,,,,
IHW=,,,,,,,,,,,,,,
NED=,,,,,,,,,,,,,,
ENG=,,,,,,,,,,,,,,
PWU=,,,,,,,,,,,,,,
VGV=,,,,,,,,,,,,,,
WDS=,,,,,,,,,,,,,,
OSS=,,,,,,,,,,,,,,
MSW=,,,,,,,,,,,,,,
DBT=,,,,,,,,,,,,,,
[Beoordeling]

script.txt

Link to comment
Share on other sites

  • Moderators

PcExpert,

All that is necessary is to force the script to show the updated tab by using GUICtrlSetState($tab1, $GUI_SHOW).

However, looking at your altered script, you do not need the GUISwitch($Gui, $tab?) lines after creating the TabItems. For one thing, GUISwitch only takes one parameter! You only need to use GUISwitch when you change the GUI, not when you create controls - so the GUISwitch($Gui) at the start of function Event() is all you need here. As I mentioned yesterday, you may need other GUISwitch calls elsewhere in your script when you display other GUIs.

I also noticed a small problem when I was testing that I did not pick up before. As it stands, if you select 2 gebruikers\.ini files in succession the existing tabs are not deleted and so you end up with 2 sets. All you need to do is to delete all possible tabs before creating new ones.

This is function Event() as I now have it - and it seems to work fine:

Func Event()
    GUISwitch($Gui)
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            
            $treemain = StringSplit(_GUICtrlTreeView_GetTree($TV), "|")
            If $treemain[1] = "Gebruikers" Then
                
                GUICtrlDelete($tab_gro)
                $tab_gro = 9999 
                GUICtrlDelete($tab_geb)  ; Added <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                $tab_geb = GUICtrlCreateTab(140, 25, 630, 380)

                $tab1 = GUICtrlCreateTabItem("Algemeen")
                
            ; GuiSwitch removed  : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                
                ;.....
                
                $tab2 = GUICtrlCreateTabItem("Cijfers")
                
            ; GuiSwitch removed  : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                
                ;.....
                    
                $tab3 = GUICtrlCreateTabItem("Beoordelingen")
                
            ; GuiSwitch removed  : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                
                ;.....
                    
                GUICtrlCreateTabItem("")
                
                GUICtrlSetState($tab1, $GUI_SHOW) ; Added <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

            Else

                GUICtrlDelete($tab_geb)
                $tab_geb = 9999 
                GUICtrlDelete($tab_gro); Added <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                $tab_gro = GUICtrlCreateTab(140, 25, 630, 380)
                
                $tab1 = GUICtrlCreateTabItem("Deelnemers")
                $tab2 = GUICtrlCreateTabItem("Absentie")
                
                GUICtrlCreateTabItem("")
                
                GUICtrlSetState($tab1, $GUI_SHOW) ; Added  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            
            EndIf
    EndSwitch
EndFunc  ;==>Event

You can see where I have added and deleted code. The ;..... is where I have omitted the working code for clarity.

I hope that lets you get on to the next stage.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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