UnitasEwokis Posted December 16, 2006 Share Posted December 16, 2006 Hi guys, i'm playing GuildWars and so i wanted to create a TreeView-Checklist with all the things, one has unlocked for that game. Therefore i need to create a GUI with a TreeView with checkboxes. The content of the TreeView should be loaded form a file, and saved to this file. I searched for a solution, but didn't find anything helpful, except this one. But i need to save the TreeView too after changes were made. My current TreeView looks like this, but there is a LOT of content to add, this is just for preview, who many subtrees i need. CODE; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.1.0 ; Author: pHoeniX ; ; Script Function: ; GW Checklist ; ; ---------------------------------------------------------------------------- #include <GUIConstants.au3> #include <file.au3> GUICreate("GW Checklist PvP",320,640, 100,100) $menu = GuiCtrlCreateMenu("Menü") $save = GuiCtrlCreateMenuItem("Speichern", $menu) $load = GUICtrlCreateMenuItem("Laden", $menu) $overview = GuiCtrlCreateTreeView(10,10, 300,600, BitOr($TVS_CHECKBOXES,$TVS_DISABLEDRAGDROP,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_HASBUTTONS)) ; $runes = GuiCtrlCreateTreeViewItem("Runen", $overview) $warrior_runes = GuiCtrlCreateTreeViewItem("Krieger", $runes) $strength_runes = GuiCtrlCreateTreeViewItem("Stärke", $warrior_runes) $strength_minor = GuiCtrlCreateTreeViewItem("kleine", $strength_runes) $strength_major = GuiCtrlCreateTreeViewItem("große", $strength_runes) $strength_superior = GuiCtrlCreateTreeViewItem("überlegene", $strength_runes) $sword_runes = GuiCtrlCreateTreeViewItem("Schwertbeherrschung", $warrior_runes) $sword_minor = GuiCtrlCreateTreeViewItem("kleine", $sword_runes) $sword_major = GuiCtrlCreateTreeViewItem("große", $sword_runes) $sword_superior = GuiCtrlCreateTreeViewItem("überlegene", $sword_runes) $axe_runes = GuiCtrlCreateTreeViewItem("Axtbeherrschung", $warrior_runes) $hammer_runes = GuiCtrlCreateTreeViewItem("Hammerbeherrschung", $warrior_runes) $tactics_runes = GuiCtrlCreateTreeViewItem("Taktik", $warrior_runes) $ranger_runes = GuiCtrlCreateTreeViewItem("Waldläufer", $runes) $expertise_runes = GuiCtrlCreateTreeViewItem("Fachkenntnis", $ranger_runes) $marksmanship_runes = GuiCtrlCreateTreeViewItem("Treffsicherheit", $ranger_runes) $wilderness_runes = GuiCtrlCreateTreeViewItem("Überleben in der Wildnis", $ranger_runes) $beast_runes = GuiCtrlCreateTreeViewItem("Tierbeherrschung", $ranger_runes) $monk_runes = GuiCtrlCreateTreeViewItem("Mönch", $runes) $divine_runes = GuiCtrlCreateTreeViewItem("Gunst der Götter", $monk_runes) $healing_runes = GuiCtrlCreateTreeViewItem("Heilgebete", $monk_runes) $protection_runes = GuiCtrlCreateTreeViewItem("Schutzgebete", $monk_runes) $smite_runes = GuiCtrlCreateTreeViewItem("Peinigungsgebete", $monk_runes) $necromancer_runes = GuiCtrlCreateTreeViewItem("Nekromant", $runes) $mesmer_runes = GuiCtrlCreateTreeViewItem("Mesmer", $runes) $elementalist_runes = GuiCtrlCreateTreeViewItem("Elementarmagier", $runes) $assassin_runes = GuiCtrlCreateTreeViewItem("Assassine", $runes) $ritualist_runes = GuiCtrlCreateTreeViewItem("Ritualist", $runes) $paragon_runes = GuiCtrlCreateTreeViewItem("Paragon", $runes) $dervish_runes = GuiCtrlCreateTreeViewItem("Derwisch", $runes) $skills = GuiCtrlCreateTreeViewItem("Fertigkeiten", $overview) $warrior_skills = GuiCtrlCreateTreeViewItem("Krieger", $skills) $strenght_skills = GuiCtrlCreateTreeViewItem("Stärke", $warrior_skills) $strenght_skills_elite = GuiCtrlCreateTreeViewItem("Elite", $strenght_skills) $bulls_charge = GuiCtrlCreateTreeViewItem("Angriff des Bullen", $strenght_skills_elite) $defy_pain = GuiCtrlCreateTreeViewItem("Schmerz trotzen", $strenght_skills_elite) $strenght_skills_non = GuiCtrlCreateTreeViewItem("Normale", $strenght_skills) $i_will_avenge_you = GuiCtrlCreateTreeViewItem("Ich werde euch rächen", $strenght_skills_non) $bersercer_stance = GuiCtrlCreateTreeViewItem("Berserker-Haltung", $strenght_skills_non) $sword_skills = GuiCtrlCreateTreeViewItem("Schwert", $warrior_skills) $axe_skills = GuiCtrlCreateTreeViewItem("Axt", $warrior_skills) $hammer_skills = GuiCtrlCreateTreeViewItem("Hammer", $warrior_skills) $tactics_skills = GuiCtrlCreateTreeViewItem("Taktik", $warrior_skills) $ranger_skills = GuiCtrlCreateTreeViewItem("Waldläufer", $skills) $upgrades = GuiCtrlCreateTreeViewItem("Aufrüstungen", $overview) GUISetState (@SW_SHOW) While 1 $msg = GuiGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit ElseIf $msg = $save Then ;;;; save function ;;;; ElseIf $msg = $load Then ;;;; load function ;;;; EndIf WEnd And is it possible, that a box is automatically checked, if all subboxes are checked? Or that all subboxes get checked, if a box is checked? Would be very nice, if anyone had an idea, how to solve this. Link to comment Share on other sites More sharing options...
Zedna Posted December 16, 2006 Share Posted December 16, 2006 (edited) I suggest you to use plain TXT file instead of INI.At each line will be one line from TreeView precceded with number of @TAB chars correspond to level of treeview item.Such TXT can be also easy edited by hand when needed.Here is code snippet for load/save such treeview from my very old Delphi project for show/edit family tree:expandcollapse popupprocedure TForm1.FormCreate(Sender: TObject); var Pole : array[0..255] of TTreeNode; Memo: TMemo; Radek: string; I, Level: Integer; begin Memo := TMemo.Create (self); Memo.Parent := self; Memo.Visible := false; Memo.Width := 1000; Memo.Lines.LoadFromFile ('rodokmen.txt'); Self.Caption := Memo.Lines[0]; Application.Title := Memo.Lines[0]; for I := 2 to Memo.Lines.Count - 1 do begin Radek := Memo.Lines[I]; Level := 1; while Radek[Level] = #9 do Inc(Level); Dec(Level); Radek := Trim(Radek); if Level = 0 then Pole[Level] := TreeView1.Items.Add (nil, Radek) else Pole[Level] := TreeView1.Items.AddChild (Pole[Level-1], Radek); end; {for} Memo.Free; end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); var CurItem: TTreeNode; Memo: TMemo; S : string; begin Memo := TMemo.Create (self); Memo.Parent := self; Memo.Visible := false; Memo.Width := 1000; Memo.Lines.Add(Self.Caption); Memo.Lines.Add(''); CurItem := TreeView1.Items.GetFirstNode; while CurItem <> nil do begin SetLength(S,CurItem.Level); FillChar(S[1],CurItem.Level,#9); Memo.Lines.Add(S + CurItem.Text); CurItem := CurItem.GetNext; end; try Memo.Lines.SaveToFile ('rodokmen.txt'); except on Exception do; {ignoruje jakoukoli chybu a nedela nic} end; {try} Memo.Free; end;For Treeview operations (get level, etc.) use Auto3Lib library from PauliAEDIT: here is link about that Edited December 16, 2006 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
UnitasEwokis Posted December 16, 2006 Author Share Posted December 16, 2006 Sry, but i can't read Delphi, but i'll try to get the other link to work. But i have enormous problems, 'cause I'm using the german version of Windows and a lot of scripts aren't working. Link to comment Share on other sites More sharing options...
Zedna Posted December 16, 2006 Share Posted December 16, 2006 I haven't too much time to write it for you from scratch. So make some start, post your code here and describe concrete problems. Then somebody surely will help you ... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
UnitasEwokis Posted December 16, 2006 Author Share Posted December 16, 2006 I haven't too much time to write it for you from scratch.So make some start, post your code here and describe concrete problems. Then somebody surely will help you ...That shouldn't sound ungrateful. Sry, i you missunderstood me, i'm glad for your answer. Link to comment Share on other sites More sharing options...
PaulIA Posted December 17, 2006 Share Posted December 17, 2006 That shouldn't sound ungrateful. Sry, i you missunderstood me, i'm glad for your answer.Just in case you didn't find an answer yet, I wanted to let you know that I'll be releasing an update to Auto3Lib shortly that will have SaveToFile and LoadFromFile methods for TreeViews. Might release this later on today depending on how the final testing goes. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
UnitasEwokis Posted December 17, 2006 Author Share Posted December 17, 2006 Just in case you didn't find an answer yet, I wanted to let you know that I'll be releasing an update to Auto3Lib shortly that will have SaveToFile and LoadFromFile methods for TreeViews. Might release this later on today depending on how the final testing goes.Dude, that would be just too great. Thx in advance, i'm looking forward to the final release. Link to comment Share on other sites More sharing options...
Zedna Posted December 17, 2006 Share Posted December 17, 2006 Just in case you didn't find an answer yet, I wanted to let you know that I'll be releasing an update to Auto3Lib shortly that will have SaveToFile and LoadFromFile methods for TreeViews. Might release this later on today depending on how the final testing goes.Hey PauliA you are the KING Could you add this Save/Load also for ListView and ListBox? I'm just now working on application for general copy data from external TreeView/ListView/Listbox controls (user clicks on them) and save it to Clipboard/File in plain TXT format (Tab delimited), ListView also with column names.I can make it myself but take it as idea for your great Library Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
PaulIA Posted December 18, 2006 Share Posted December 18, 2006 Hey PauliA you are the KING Could you add this Save/Load also for ListView and ListBox? I'm just now working on application for general copy data from external TreeView/ListView/Listbox controls (user clicks on them) and save it to Clipboard/File in plain TXT format (Tab delimited), ListView also with column names.I can make it myself but take it as idea for your great Library I put out the new release. Let me know if you have any questions/problems. I'll put the Save/Load functions on "The List" for the next releases Check the TreeView demo out to see if this type of save format is acceptable for the other controls. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
UnitasEwokis Posted December 18, 2006 Author Share Posted December 18, 2006 Hi, the save function works great, but i have problems with the load funtion. It doesn't work, not even in your example (TreeView2.au3). Always, i'm clicking [Load] it crashes with message "_TreeView_LoadFromFile: -4" Link to comment Share on other sites More sharing options...
PaulIA Posted December 18, 2006 Share Posted December 18, 2006 Hi, the save function works great, but i have problems with the load funtion. It doesn't work, not even in your example (TreeView2.au3). Always, i'm clicking [Load] it crashes with message "_TreeView_LoadFromFile: -4"I see the problem. I'll put out a fix for this in the next release. If this is something you need immediately, PM me and I'll send you the patched code. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
UnitasEwokis Posted December 18, 2006 Author Share Posted December 18, 2006 (edited) ... in the next release. If this is something you need immediately...Depends on, how the next release will be ;-)I have to implement all the content, so i need time anyways. Edited December 18, 2006 by UnitasEwokis Link to comment Share on other sites More sharing options...
Zedna Posted December 19, 2006 Share Posted December 19, 2006 I put out the new release. Let me know if you have any questions/problems. I'll put the Save/Load functions on "The List" for the next releases Check the TreeView demo out to see if this type of save format is acceptable for the other controls.Thanks PaulIAFor my purposes I will make my own format. But your way is good in it's generality. So by me your format could be used also for other controls.Only one thing: when you make code for item states you may then code also item level directly to number instead of several spaces but it's subjective. I prefer several tabs but maybe in your code it could be the same as other item properties. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
PaulIA Posted December 19, 2006 Share Posted December 19, 2006 Thanks PaulIAFor my purposes I will make my own format. But your way is good in it's generality. So by me your format could be used also for other controls.Only one thing: when you make code for item states you may then code also item level directly to number instead of several spaces but it's subjective. I prefer several tabs but maybe in your code it could be the same as other item properties.Actually, I did the layout that way so that you could open the file and view the contents with the level indention. Sort of a visual representation of the TreeView in text format. I figured this would be easiest for the n00bs to debug. If I'd have done this for myself, the file would have been in binary format. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
ReFran Posted December 19, 2006 Share Posted December 19, 2006 (edited) Only one thing: when you make code for item states you may then code also item level directly to number instead of several spaces but it's subjective. I prefer several tabs but maybe in your code it could be the same as other item properties.I read the items in and out with a trailing "#" and spaces, based on an idea from valuater.That makes it easy to identify the level (stringInStr) and also to edit in an editor or editorbox. The Treeview I need mainly for PDF handling. With above format it is easy to read Adobes PDF bookmarks out and in, with some translations for the different programms, which can be used to influence(read/write) PDF bookmarks.However, thank for your work on this item, Reinhard Edited December 19, 2006 by ReFran Link to comment Share on other sites More sharing options...
FlavioBlumenau Posted July 26, 2015 Share Posted July 26, 2015 Zedna, thank very much, I was looking for this wich xml, but having problems on load xml. So this will help me a lot.regards from Blumenau, SC, Brazil. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 26, 2015 Moderators Share Posted July 26, 2015 FlavioBlumenau,Welcome to the AutoIt forums.Did you notice that the post above yours in this thread dates from some 9 years ago?Please do not necro-post like this again - particularly just to say "thanks". If you have a similar question just open a new thread and link to the old one if it is absolutely necessary for understanding the problem. We ask you to do this for two main reasons:The language advances and the functionality might well be included in core or UDF code by now.The changes in language syntax mean that it is likely that code from more than a couple of years ago may well not run under the current release interpreter without significant modification.Thanks in advance for your cooperation.M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Blue_Drache Posted July 26, 2015 Share Posted July 26, 2015 *looks left ...*looks right* ... PARTIES IN THE UNLOCKED NECROTHREAD LIKE A ZOMBIE! Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 26, 2015 Moderators Share Posted July 26, 2015 Sigh,I thought that posting in, but not locking, the thread would be sufficient - obviously zombies (particularly of the blue-winged type) cannot take a hint. And so.....M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts