Sublime Posted March 30, 2009 Share Posted March 30, 2009 (edited) EDIT1: SEE POST #4I have looked around and have found many examples with listboxes and such... But I am trying to create a description label read from an ini file based on the currently selected tree view item.I am trying to get the currently selected TreeView Item... I use _GuiCtrlTreeView_GetSelection... That is dandy.. I Have this in my While loop...$Selection = _GuiCtrlTreeView_GetSelection($AppTree) $Description = _GUICtrlTreeView_GetText(_GuiCtrlTreeView_GetSelection($AppTree)) If $Selection <> 0 Then GUICtrlCreateLabel(IniRead($Descriptions, "Descriptions", $Description, ""), 4, 395)For somereason it just keeps throwin up the descriptions for all items just one after another as if i was clicking on all the items one after another. Then once I actually do click on an item it stops on that items description then the script exits....I have been going at this thing for about 2 hrs and it drivin me nuts as it should be simple but it just eluding me.Someone elightin me O_o Edited March 30, 2009 by Sublime Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 30, 2009 Moderators Share Posted March 30, 2009 Sublime,At first glance it looks like a syntax problem - you need the handles for both the TreeView and the selected Item (as returned by _GUICtrlTreeView_Add) in the _GUICtrlTreeView_GetText call.I suggest you use an array to hold the Item handles (as shown in the Help file example):_GUICtrlTreeView_BeginUpdate($hTreeView) For $x = 0 To ..... $hItem[$x] = _GUICtrlTreeView_Add($hTreeView, 0, $New_Item) Next _GUICtrlTreeView_EndUpdate($hTreeView)and then use something like this to get the text:$Description = __GUICtrlTreeView_GetText($hTreeView, $hItem[$Selection])If this does not work, post a bit more code - what we have so far is a bit thin......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...
Sublime Posted March 30, 2009 Author Share Posted March 30, 2009 Well see in my tree I have all the control held by an array and everything works fine the array reads from the ini files fills in nicely reacts to selected items as I am using the checkbox option. I am just adding this to give a bit more explanation on each of the items prior to checking them off as an option. I understand the code there was skimp.... My program is currently 1800 lines of code so to just throw it up would be counteractive to solving the problem as it is just to much... I am currently throwin together a gui of somewhat similarity to what I am trying to do so we can move forward with the problem. Ill be posting the code that demonstrates the error shortly Link to comment Share on other sites More sharing options...
Sublime Posted March 30, 2009 Author Share Posted March 30, 2009 (edited) Well this more or less demonstrates the basic concept of what I am trying to accomplish.... Anyone any thoughts??? I cant get it to properly update the label... I've tried using GuiCtrlSetData also to no avail.... expandcollapse popup#include <GUIConstantsEx.au3> #Include <GuiTreeView.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> $Form1_1 = GUICreate("Form1", 536, 536, 251, 124) GUISetBkColor(0xDADBE5) Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) $TreeView1 = GUICtrlCreateTreeView(8, 56, 521, 313, $iStyle, $WS_EX_CLIENTEDGE) _GUICtrlTreeView_BeginUpdate($TreeView1) ;====================================Start GUI Tree#1============================================== $TREE1 = _GUICtrlTreeView_Add($TreeView1, "", "Applications") Local $Applications[10], $Tree1_Item[10] ;Populate Array For $x = 1 To 9 $Random = Random(1, 10, 1) $Applications[$x] = $Random Next For $x = 1 To UBound($Applications) - 1 $Tree1_Item[$x] = _GUICtrlTreeView_AddChild($TreeView1, $TREE1, $Applications[$x], "") Next ;====================================Start GUI Tree#1============================================== _GUICtrlTreeView_EndUpdate($TreeView1) $Group1 = GUICtrlCreateGroup("ITEM DESCRIPTION", 8, 376, 521, 73) $Button1 = GUICtrlCreateButton("EXIT", 216, 456, 113, 25, 0) $Label1 = GUICtrlCreateLabel("GUI FOR TESTING ERRORS", 16, 16, 147, 17) GUISetState(@SW_SHOW) While 1 $Selection = _GuiCtrlTreeView_GetSelection($TreeView1) If $Selection <> 0 Then GUICtrlCreateLabel($Selection, 16, 392) _GUICtrlTreeView_SetSelected($TreeView1, $Selection, False) $Selection = 0 EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit EndSwitch WEnd Edited March 30, 2009 by Sublime Link to comment Share on other sites More sharing options...
Authenticity Posted March 30, 2009 Share Posted March 30, 2009 expandcollapse popup#include <GUIConstantsEx.au3> #Include <GuiTreeView.au3> #include <WindowsConstants.au3> $Form1_1 = GUICreate("Form1", 536, 536, 251, 124) GUISetBkColor(0xDADBE5) Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) $TreeView1 = GUICtrlCreateTreeView(8, 56, 521, 313, $iStyle, $WS_EX_CLIENTEDGE) $hTreeView1 = GUICtrlGetHandle(-1) GUIRegisterMsg($WM_NOTIFY, '_OnNotify') _GUICtrlTreeView_BeginUpdate($TreeView1) ;====================================Start GUI Tree#1============================================== $TREE1 = _GUICtrlTreeView_Add($TreeView1, "", "Applications") Local $Applications[10], $Tree1_Item[10] ;Populate Array For $x = 1 To 9 $Random = Random(1, 10, 1) $Applications[$x] = $Random Next For $x = 1 To UBound($Applications) - 1 $Tree1_Item[$x] = _GUICtrlTreeView_AddChild($TreeView1, $TREE1, $Applications[$x], "") Next ;====================================Start GUI Tree#1============================================== _GUICtrlTreeView_EndUpdate($TreeView1) $Group1 = GUICtrlCreateGroup("ITEM DESCRIPTION", 8, 376, 521, 73) $Button1 = GUICtrlCreateButton("EXIT", 216, 456, 113, 25, 0) $Label1 = GUICtrlCreateLabel("GUI FOR TESTING ERRORS", 16, 16, 147, 17) $Label2 = GUICtrlCreateLabel('', 16, 392, 70, 23) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit EndSwitch Sleep(20) WEnd Func _OnNotify($hWnd, $iMsg, $iwParam, $ilParam) Local $tNM_TREEVIEW, $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) If DllStructGetData($tNMHDR, 'hwndFrom') = $hTreeView1 Then If DllStructGetData($tNMHDR, 'Code') = $TVN_SELCHANGEDW Then $tNM_TREEVIEW = DllStructCreate($tagNMTREEVIEW, $ilParam) GUICtrlSetData($Label2, _GUICtrlTreeView_GetText _ ($hTreeView1, DllStructGetData($tNM_TREEVIEW, 'NewhItem'))) EndIf EndIf Return $GUI_RUNDEFMSG EndFunc Maybe you prefer to handle it using event handler? Link to comment Share on other sites More sharing options...
Sublime Posted March 30, 2009 Author Share Posted March 30, 2009 Thx that works great.... I wish I understood more about the DllStruct function but hey.. That can come later on.. Link to comment Share on other sites More sharing options...
Authenticity Posted March 30, 2009 Share Posted March 30, 2009 I think you need to get your self "Win32 Programmer's Reference", if you know what each argument may contain upon certain event you may know which function to use. 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