gcue Posted March 10, 2009 Share Posted March 10, 2009 do i need to do some sort of inireload or something? i cant get the treeview to show realtime changes. _GUICtrlTreeView_BeginUpdate($editINI_treeview) IniDelete($aINI, $section, $pc_label) IniWrite($aINI, $section, $label, $asset) _GUICtrlTreeView_EndUpdate($editINI_treeview) Link to comment Share on other sites More sharing options...
Zedna Posted March 10, 2009 Share Posted March 10, 2009 Yes. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
GEOSoft Posted March 10, 2009 Share Posted March 10, 2009 (edited) We will require a bit more info than that. Can you show how you are creating the TreeView? Does it have static and dynamic elements? Are you adding elements dynamically at runtime? What information will change? I use a very large tree where the tree has certain static elements and then Dynamic elements are added at runtime. If there are changes it calls a _RefreshTree() func that deletes all of the dynamic elements and then rebuilds them. The trick to that is to use a Dummy control as the last control in the GUI and another as the last control in the dynamic elements list or at least a count of the dynamic elements so you have something to reference in a For / Next loop. Edited March 10, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
gcue Posted March 10, 2009 Author Share Posted March 10, 2009 what does an INIreload look like? inireadsectionnames then rebuild the tree? is there an easier way? Link to comment Share on other sites More sharing options...
gcue Posted March 10, 2009 Author Share Posted March 10, 2009 We will require a bit more info than that. Can you show how you are creating the TreeView? Does it have static and dynamic elements? Are you adding elements dynamically at runtime? What information will change? I use a very large tree where the tree has certain static elements and then Dynamic elements are added at runtime. If there are changes it calls a _RefreshTree() func that deletes all of the dynamic elements and then rebuilds them. The trick to that is to use a Dummy control as the last control in the GUI and another as the last control in the dynamic elements list or at least a count of the dynamic elements so you have something to reference in a For / Next loop. here's how i build it (data residing in an INI file) - pretty static to answer ur question (until someone edits it) $asset_locs = IniReadSectionNames($aINI) For $x = 1 To $asset_locs[0] $asset_loc_suffix = StringRight($asset_locs[$x], 7) If $asset_loc_suffix = "_ASSETS" Or $asset_loc_suffix = "TARGETS" Then $group = GUICtrlCreateTreeViewItem($asset_locs[$x], $editINI_treeview) GUICtrlSetColor(-1, 0x0000C0) $assets = IniReadSection($aINI, $asset_locs[$x]) For $y = 1 To $assets[0][0] $pc = GUICtrlCreateTreeViewItem($assets[$y][0], $group) GUICtrlSetColor(-1, 0x0000C0) $item_menu = GUICtrlCreateContextMenu($pc) $item_edit = GUICtrlCreateMenuItem("Edit", $item_menu) GUICtrlSetOnEvent(-1, "INI_Item_Edit_GUI") Next EndIf Next Link to comment Share on other sites More sharing options...
GEOSoft Posted March 10, 2009 Share Posted March 10, 2009 (edited) Put that in a Function called _TreeRefresh() or what ever Then use something similar to below. expandcollapse popup$sIni = FileRead($aIni) $Frm_Main = GUICreate("My Test Form") $tree = GUICtrlCreateTreeView("", 10, 10, 100, 100) $hStart = GUICtrlCreateDummy() _TreeRefresh() $hEnd = GUICtrlCreateDummy() GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 Exit Case Else EndSwitch If FileRead($aIni) <> $sIni Then For $i = $hStart+1 To $hEnd GUICtrlDelete($i) Next _TreeRefresh() $hEnd = GUICtrlCreateDummy() $sIni = FileRead($aIni) EndIf WEnd Func _TreeRefresh() $asset_locs = IniReadSectionNames($aINI) For $x = 1 To $asset_locs[0] $asset_loc_suffix = StringRight($asset_locs[$x], 7) If $asset_loc_suffix = "_ASSETS" Or $asset_loc_suffix = "TARGETS" Then $group = GUICtrlCreateTreeViewItem($asset_locs[$x], $editINI_treeview) GUICtrlSetColor(-1, 0x0000C0) $assets = IniReadSection($aINI, $asset_locs[$x]) For $y = 1 To $assets[0][0] $pc = GUICtrlCreateTreeViewItem($assets[$y][0], $group) GUICtrlSetColor(-1, 0x0000C0) $item_menu = GUICtrlCreateContextMenu($pc) $item_edit = GUICtrlCreateMenuItem("Edit", $item_menu) GUICtrlSetOnEvent(-1, "INI_Item_Edit_GUI") Next EndIf Next EndFunc Without digging through one of my apps to double check, this should be pretty close. You might have to tweak it a bit but the important part is where you declare $hStart and $hEnd. They must be after all the other controls. You could also put them inside the function to make it simple but remember to declare them as Global variables. I didn't do that because I was refreshing either of 2 TreeViews with the same functions so I had 2 start and end points. Edit: I should have added the fact that there are also some functions in GuiTreeView.au3 that you can use. You will find them in the help file under User Defined Functions>>TreeView Management. I just found it easier in my case to delete them all and then rebuild the tree. Edited March 10, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
gcue Posted March 10, 2009 Author Share Posted March 10, 2009 (edited) hehe wow.. looks funny when its updating - but it works =D thanks =) Edited March 10, 2009 by gcue Link to comment Share on other sites More sharing options...
GEOSoft Posted March 10, 2009 Share Posted March 10, 2009 (edited) hehe wow.. looks funny when its updating - but it works =Dthanks =)NP. If the treeView is collapsed you won't have that funny look. BTW: With mine I had some static branches that were not changed so I was only refreshing the subs.EDIT: A quick tweak for that funny look is to hide the TreeView control during the refresh. Edited March 10, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
gcue Posted March 10, 2009 Author Share Posted March 10, 2009 (edited) have u seen sandin's utility?http://www.autoitscript.com/forum/index.ph...c=85992&hl=its awesome.. not sure how he does his refreshing Edited March 10, 2009 by gcue Link to comment Share on other sites More sharing options...
GEOSoft Posted March 10, 2009 Share Posted March 10, 2009 have u seen sandin's utility?http://www.autoitscript.com/forum/index.ph...c=85992&hl=its awesome.. not sure how he does his refreshingsandin always does a nice job. There are a few ways to handle your situation. I jusy gave you the quick and dirty one. The rest is up to you. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
gcue Posted March 10, 2009 Author Share Posted March 10, 2009 thanks again =) Link to comment Share on other sites More sharing options...
GEOSoft Posted March 10, 2009 Share Posted March 10, 2009 YW The good part is that it works as requested. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now