lsakizada Posted July 9, 2009 Share Posted July 9, 2009 Did someone know if it possible to have TreeView item that the item text can be selected from a dropdown combobox. Be Green Now or Never (BGNN)! Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 9, 2009 Share Posted July 9, 2009 Did someone know if it possible to have TreeView item that the item text can be selected from a dropdown combobox.I think you would have to layer a separate ComboBox control over the TreeView, on the item's coordinates. Doesn't sound impossible, but painful enough to need a good reason to do it. What's it for? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
lsakizada Posted July 9, 2009 Author Share Posted July 9, 2009 I think you would have to layer a separate ComboBox control over the TreeView, on the item's coordinates. Doesn't sound impossible, but painful enough to need a good reason to do it. What's it for? I modified the INI Editor and using it as a configuration tool. I want to restrict user to select hot keys from a drop down combo when configuring new param's value.It could be very useful if I will suceed, but I do not see any hope Be Green Now or Never (BGNN)! Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 9, 2009 Share Posted July 9, 2009 I modified the INI Editor and using it as a configuration tool. I want to restrict user to select hot keys from a drop down combo when configuring new param's value.It could be very useful if I will suceed, but I do not see any hope No need to do that ON the TreeView, though. When it gets selected can popup a dialog, or enable/disable a ComboBox control in the same GUI as required. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
lsakizada Posted July 19, 2009 Author Share Posted July 19, 2009 (edited) No need to do that ON the TreeView, though. When it gets selected can popup a dialog, or enable/disable a ComboBox control in the same GUI as required. BUMP!I was unable to set a popoup dropdown box on editing treeview item.I was able to detect and launch windows on editing item but it is realy not the solution. Edited July 19, 2009 by lsakizada Be Green Now or Never (BGNN)! Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 20, 2009 Share Posted July 20, 2009 BUMP!I was unable to set a popoup dropdown box on editing treeview item.I was able to detect and launch windows on editing item but it is realy not the solution.I would not allow treeview item editing at all. Just have an edit button, or some way for the user to indicate they want to edit the selected item, and that either pops up a dialog or enables a separate combobox to select the new value. On selecting the new value, it would be updated on the treeview item. The built-in item edit is an unnecessary complication since you need control over the possible values.If you want to get down to specific code, post a small reproducer script as a demo of the issue, and we can figure it out. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
lsakizada Posted August 7, 2009 Author Share Posted August 7, 2009 If you want to get down to specific code, post a small reproducer script as a demo of the issue, and we can figure it out. >_<Actually, the INI Editor allow to edit tree items. I realy need this to work and I will appreciate that much.http://www.autoitscript.com/forum/index.php?showtopic=85992&hl=ini%20editor&st=0Sorry for the late response. I was on traveling. Be Green Now or Never (BGNN)! Link to comment Share on other sites More sharing options...
martin Posted August 7, 2009 Share Posted August 7, 2009 Actually, the INI Editor allow to edit tree items. I realy need this to work and I will appreciate that much. http://www.autoitscript.com/forum/index....php?showtopic=85992&hl=ini%20editor&st=0 Sorry for the late response. I was on traveling. Here is a rather rushed example by using the help example and a function by El Torro and Zedna. Maybe you can make something of it. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <TreeViewConstants.au3> #include <StaticConstants.au3> #include <sendmessage.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $treeview, $generalitem, $displayitem, $aboutitem, $compitem Local $useritem, $resitem, $otheritem, $startlabel, $aboutlabel, $compinfo Local $togglebutton, $infobutton, $statebutton, $cancelbutton Local $msg, $item, $hItem, $text Local $mgGui, $rect1, $cb $mgGui = GUICreate("My GUI with treeview", 350, 215) $cb = GUICtrlCreateCombo("hhh", 880, 30, 120, 16) $treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($WS_CLIPSIBLINGS,$TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) $generalitem = GUICtrlCreateTreeViewItem("General", $treeview) GUICtrlSetColor(-1, 0x0000C0) $displayitem = GUICtrlCreateTreeViewItem("Display", $treeview) GUICtrlSetColor(-1, 0x0000C0) $aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem) $compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem) $useritem = GUICtrlCreateTreeViewItem("User", $generalitem) $resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem) $otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem) $startlabel = GUICtrlCreateLabel("TreeView Demo", 190, 90, 100, 20,$WS_CLIPSIBLINGS) $aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60,$WS_CLIPSIBLINGS) GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "aboutlabel"-text during initialization $compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 180, 30, 200, 80,$WS_CLIPSIBLINGS) GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "compinfo"-text during initialization GUICtrlCreateLabel("", 0, 170, 350, 2, $SS_SUNKEN) $togglebutton = GUICtrlCreateButton("&Toggle", 35, 185, 70, 20) $infobutton = GUICtrlCreateButton("&Info", 105, 185, 70, 20) $statebutton = GUICtrlCreateButton("Col./Exp.", 175, 185, 70, 20) $cancelbutton = GUICtrlCreateButton("&Cancel", 245, 185, 70, 20) GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold GUICtrlSetState($displayitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "Display"-item and paint in bold ;$cb = GUICtrlCreateCombo("hhh", 10, 30, 120, 16) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $togglebutton ; Toggle the bold painting If BitAND(GUICtrlRead($generalitem), $GUI_DEFBUTTON) Then GUICtrlSetState($generalitem, 0) GUICtrlSetState($displayitem, 0) Else GUICtrlSetState($generalitem, $GUI_DEFBUTTON) GUICtrlSetState($displayitem, $GUI_DEFBUTTON) EndIf Case $msg = $infobutton $item = GUICtrlRead($treeview) ; Get the controlID of the current selected treeview item If $item = 0 Then MsgBox(64, "TreeView Demo", "No item currently selected") Else $text = GUICtrlRead($item, 1) ; Get the text of the treeview item If $text == "" Then MsgBox(16, "Error", "Error while retrieving infos about item") Else MsgBox(64, "TreeView Demo", "Current item selected is: " & $text); $advmsg[0] contains the text and $advmsg[1] the state value of the treeview item EndIf EndIf Case $msg = $statebutton $item = GUICtrlRead($treeview) If $item > 0 Then $hItem = GUICtrlGetHandle($item) GUICtrlSendMsg($treeview, $TVM_EXPAND, $TVE_TOGGLE, $hItem) EndIf ; The following items will hide the other labels (1st and 2nd parameter) and then show the 'own' labels (3rd and 4th parameter) Case $msg = $generalitem $item = GUICtrlRead($treeview) If $item > 0 Then $hItem = GUICtrlGetHandle($item) $rect1 = _GuiCtrlTreeViewGetItemRect($treeview, $hItem, True, 1) ControlMove($mgGui, "", $cb, $rect1[0], $rect1[1], $rect1[2], 16) EndIf GUIChangeItems($aboutlabel, $compinfo, $startlabel, $startlabel) Case $msg = $aboutitem $item = GUICtrlRead($treeview) If $item > 0 Then $hItem = GUICtrlGetHandle($item) $rect1 = _GuiCtrlTreeViewGetItemRect($treeview, $hItem, True, 1) ControlMove($mgGui, "", $cb, $rect1[0], $rect1[1], $rect1[2], 16) EndIf GUICtrlSetState($compinfo, $GUI_HIDE) GUIChangeItems($startlabel, $startlabel, $aboutlabel, $aboutlabel) Case $msg = $compitem $item = GUICtrlRead($treeview) If $item > 0 Then $hItem = GUICtrlGetHandle($item) $rect1 = _GuiCtrlTreeViewGetItemRect($treeview, $hItem, True, 1) ControlMove($mgGui, "", $cb, $rect1[0], $rect1[1], $rect1[2], 16) EndIf GUIChangeItems($startlabel, $aboutlabel, $compinfo, $compinfo) Case $msg = $resitem Or $msg = $otheritem Or $msg = $useritem $item = GUICtrlRead($treeview) If $item > 0 Then $hItem = GUICtrlGetHandle($item) $rect1 = _GuiCtrlTreeViewGetItemRect($treeview, $hItem, True, 1) ControlMove($mgGui, "", $cb, $rect1[0], $rect1[1], $rect1[2], 16) EndIf EndSelect WEnd GUIDelete() EndFunc ;==>Example Func GUIChangeItems($hidestart, $hideend, $showstart, $showend) Local $idx For $idx = $hidestart To $hideend GUICtrlSetState($idx, $GUI_HIDE) Next For $idx = $showstart To $showend GUICtrlSetState($idx, BitOr($GUI_SHOW,$GUI_DISABLE)) Next EndFunc ;==>GUIChangeItems ;by El Torro, Zedna Func _GuiCtrlTreeViewGetItemRect($i_treeview, $h_item, $b_flag = True, $i_mode = 2) Local $st_Rect = DllStructCreate("int;int;int;int") If @error Then Return 0 Local $retval[4];, $TVM_GETITEMRECT = (0x1100 + 4) ;$TV_FIRST + 4 DllStructSetData($st_Rect, 1, $h_item);GUICtrlGetHandle($h_item)) If GUICtrlSendMsg($i_treeview, $TVM_GETITEMRECT, $b_flag, DllStructGetPtr($st_Rect)) = 30 Then ConsoleWrite("retuning 0" & @CRLF) Return 0 EndIf For $x = 0 To 3 $retval[$x] = DllStructGetData($st_Rect, $x + 1) Next If $i_mode = 0 Then Return $retval Local $tv_pos = ControlGetPos("", "", $i_treeview) Switch $i_mode Case 1 $retval[0] += $tv_pos[0] $retval[1] += $tv_pos[1] $retval[2] += $tv_pos[0] $retval[3] += $tv_pos[1] Case 2 $retval[2] -= $retval[0] $retval[3] -= $retval[1] $retval[0] += $tv_pos[0] $retval[1] += $tv_pos[1] EndSwitch ConsoleWrite($retval[0] & ', ' & $retval[1] & ', ' & $retval[2] & ', ' & $retval[3] & ', ' & @CRLF) Return $retval EndFunc ;==>_GuiCtrlTreeViewGetItemRect Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
lsakizada Posted August 9, 2009 Author Share Posted August 9, 2009 (edited) Here is a rather rushed example by using the help example and a function by El Torro and Zedna. Maybe you can make something of it. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <TreeViewConstants.au3> #include <StaticConstants.au3> #include <sendmessage.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $treeview, $generalitem, $displayitem, $aboutitem, $compitem Local $useritem, $resitem, $otheritem, $startlabel, $aboutlabel, $compinfo Local $togglebutton, $infobutton, $statebutton, $cancelbutton Local $msg, $item, $hItem, $text Local $mgGui, $rect1, $cb $mgGui = GUICreate("My GUI with treeview", 350, 215) $cb = GUICtrlCreateCombo("hhh", 880, 30, 120, 16) $treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($WS_CLIPSIBLINGS,$TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) $generalitem = GUICtrlCreateTreeViewItem("General", $treeview) GUICtrlSetColor(-1, 0x0000C0) $displayitem = GUICtrlCreateTreeViewItem("Display", $treeview) GUICtrlSetColor(-1, 0x0000C0) $aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem) $compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem) $useritem = GUICtrlCreateTreeViewItem("User", $generalitem) $resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem) $otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem) $startlabel = GUICtrlCreateLabel("TreeView Demo", 190, 90, 100, 20,$WS_CLIPSIBLINGS) $aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60,$WS_CLIPSIBLINGS) GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "aboutlabel"-text during initialization $compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 180, 30, 200, 80,$WS_CLIPSIBLINGS) GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "compinfo"-text during initialization GUICtrlCreateLabel("", 0, 170, 350, 2, $SS_SUNKEN) $togglebutton = GUICtrlCreateButton("&Toggle", 35, 185, 70, 20) $infobutton = GUICtrlCreateButton("&Info", 105, 185, 70, 20) $statebutton = GUICtrlCreateButton("Col./Exp.", 175, 185, 70, 20) $cancelbutton = GUICtrlCreateButton("&Cancel", 245, 185, 70, 20) GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold GUICtrlSetState($displayitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "Display"-item and paint in bold ;$cb = GUICtrlCreateCombo("hhh", 10, 30, 120, 16) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $togglebutton ; Toggle the bold painting If BitAND(GUICtrlRead($generalitem), $GUI_DEFBUTTON) Then GUICtrlSetState($generalitem, 0) GUICtrlSetState($displayitem, 0) Else GUICtrlSetState($generalitem, $GUI_DEFBUTTON) GUICtrlSetState($displayitem, $GUI_DEFBUTTON) EndIf Case $msg = $infobutton $item = GUICtrlRead($treeview) ; Get the controlID of the current selected treeview item If $item = 0 Then MsgBox(64, "TreeView Demo", "No item currently selected") Else $text = GUICtrlRead($item, 1) ; Get the text of the treeview item If $text == "" Then MsgBox(16, "Error", "Error while retrieving infos about item") Else MsgBox(64, "TreeView Demo", "Current item selected is: " & $text); $advmsg[0] contains the text and $advmsg[1] the state value of the treeview item EndIf EndIf Case $msg = $statebutton $item = GUICtrlRead($treeview) If $item > 0 Then $hItem = GUICtrlGetHandle($item) GUICtrlSendMsg($treeview, $TVM_EXPAND, $TVE_TOGGLE, $hItem) EndIf ; The following items will hide the other labels (1st and 2nd parameter) and then show the 'own' labels (3rd and 4th parameter) Case $msg = $generalitem $item = GUICtrlRead($treeview) If $item > 0 Then $hItem = GUICtrlGetHandle($item) $rect1 = _GuiCtrlTreeViewGetItemRect($treeview, $hItem, True, 1) ControlMove($mgGui, "", $cb, $rect1[0], $rect1[1], $rect1[2], 16) EndIf GUIChangeItems($aboutlabel, $compinfo, $startlabel, $startlabel) Case $msg = $aboutitem $item = GUICtrlRead($treeview) If $item > 0 Then $hItem = GUICtrlGetHandle($item) $rect1 = _GuiCtrlTreeViewGetItemRect($treeview, $hItem, True, 1) ControlMove($mgGui, "", $cb, $rect1[0], $rect1[1], $rect1[2], 16) EndIf GUICtrlSetState($compinfo, $GUI_HIDE) GUIChangeItems($startlabel, $startlabel, $aboutlabel, $aboutlabel) Case $msg = $compitem $item = GUICtrlRead($treeview) If $item > 0 Then $hItem = GUICtrlGetHandle($item) $rect1 = _GuiCtrlTreeViewGetItemRect($treeview, $hItem, True, 1) ControlMove($mgGui, "", $cb, $rect1[0], $rect1[1], $rect1[2], 16) EndIf GUIChangeItems($startlabel, $aboutlabel, $compinfo, $compinfo) Case $msg = $resitem Or $msg = $otheritem Or $msg = $useritem $item = GUICtrlRead($treeview) If $item > 0 Then $hItem = GUICtrlGetHandle($item) $rect1 = _GuiCtrlTreeViewGetItemRect($treeview, $hItem, True, 1) ControlMove($mgGui, "", $cb, $rect1[0], $rect1[1], $rect1[2], 16) EndIf EndSelect WEnd GUIDelete() EndFunc ;==>Example Func GUIChangeItems($hidestart, $hideend, $showstart, $showend) Local $idx For $idx = $hidestart To $hideend GUICtrlSetState($idx, $GUI_HIDE) Next For $idx = $showstart To $showend GUICtrlSetState($idx, BitOr($GUI_SHOW,$GUI_DISABLE)) Next EndFunc ;==>GUIChangeItems ;by El Torro, Zedna Func _GuiCtrlTreeViewGetItemRect($i_treeview, $h_item, $b_flag = True, $i_mode = 2) Local $st_Rect = DllStructCreate("int;int;int;int") If @error Then Return 0 Local $retval[4];, $TVM_GETITEMRECT = (0x1100 + 4) ;$TV_FIRST + 4 DllStructSetData($st_Rect, 1, $h_item);GUICtrlGetHandle($h_item)) If GUICtrlSendMsg($i_treeview, $TVM_GETITEMRECT, $b_flag, DllStructGetPtr($st_Rect)) = 30 Then ConsoleWrite("retuning 0" & @CRLF) Return 0 EndIf For $x = 0 To 3 $retval[$x] = DllStructGetData($st_Rect, $x + 1) Next If $i_mode = 0 Then Return $retval Local $tv_pos = ControlGetPos("", "", $i_treeview) Switch $i_mode Case 1 $retval[0] += $tv_pos[0] $retval[1] += $tv_pos[1] $retval[2] += $tv_pos[0] $retval[3] += $tv_pos[1] Case 2 $retval[2] -= $retval[0] $retval[3] -= $retval[1] $retval[0] += $tv_pos[0] $retval[1] += $tv_pos[1] EndSwitch ConsoleWrite($retval[0] & ', ' & $retval[1] & ', ' & $retval[2] & ', ' & $retval[3] & ', ' & @CRLF) Return $retval EndFunc ;==>_GuiCtrlTreeViewGetItemRect Hi Martin, Thanks for the help. I have got the concept and its works for me in other way (poping up window instead of combobox only). But I was unable to popup the window next to the item's tree rectangle. i am using the GuiCtrlTreeViewGetItemRect function. is there any other method that could help? Maybe I need to conver the return values, like screen to client? I just lost .. I am using it that way: local $A=_GuiCtrlTreeViewGetItemRect($treeview, _GUICtrlTreeView_GetSelection($treeview), True, 2) Edited August 9, 2009 by lsakizada Be Green Now or Never (BGNN)! Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 10, 2009 Share Posted August 10, 2009 Hi Martin, Thanks for the help. I have got the concept and its works for me in other way (poping up window instead of combobox only). But I was unable to popup the window next to the item's tree rectangle. i am using the GuiCtrlTreeViewGetItemRect function. is there any other method that could help? Maybe I need to conver the return values, like screen to client? I just lost .. I am using it that way: local $A=_GuiCtrlTreeViewGetItemRect($treeview, _GUICtrlTreeView_GetSelection($treeview), True, 2) You want the X position for the combo to be offset from the right edge of the parent treeview, not the item: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUITreeView.au3> #include <TreeViewConstants.au3> #include <StaticConstants.au3> #include <sendmessage.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $treeview, $avTreeViewPos, $iComboX, $generalitem, $displayitem, $aboutitem, $compitem Local $useritem, $resitem, $otheritem, $startlabel, $aboutlabel, $compinfo Local $togglebutton, $infobutton, $statebutton, $cancelbutton Local $msg, $item, $hItem, $text Local $mgGui, $rect1, $cb $mgGui = GUICreate("My GUI with treeview", 350, 215) $cb = GUICtrlCreateCombo("hh", 880, 30, 120, 16) $treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($WS_CLIPSIBLINGS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) $avTreeViewPos = ControlGetPos($mgGui, "", $treeview) $iComboX = $avTreeViewPos[0] + $avTreeViewPos[2] + 6 ; Right edge of treeview control +6 for floating combo $generalitem = GUICtrlCreateTreeViewItem("General", $treeview) GUICtrlSetColor(-1, 0x0000C0) $displayitem = GUICtrlCreateTreeViewItem("Display", $treeview) GUICtrlSetColor(-1, 0x0000C0) $aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem) $compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem) $useritem = GUICtrlCreateTreeViewItem("User", $generalitem) $resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem) $otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem) $startlabel = GUICtrlCreateLabel("TreeView Demo", 190, 90, 100, 20, $WS_CLIPSIBLINGS) $aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60, $WS_CLIPSIBLINGS) GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "aboutlabel"-text during initialization $compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 180, 30, 200, 80, $WS_CLIPSIBLINGS) GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "compinfo"-text during initialization GUICtrlCreateLabel("", 0, 170, 350, 2, $SS_SUNKEN) $togglebutton = GUICtrlCreateButton("&Toggle", 35, 185, 70, 20) $infobutton = GUICtrlCreateButton("&Info", 105, 185, 70, 20) $statebutton = GUICtrlCreateButton("Col./Exp.", 175, 185, 70, 20) $cancelbutton = GUICtrlCreateButton("&Cancel", 245, 185, 70, 20) GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold GUICtrlSetState($displayitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "Display"-item and paint in bold ;$cb = GUICtrlCreateCombo("hhh", 10, 30, 120, 16) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $togglebutton ; Toggle the bold painting If BitAND(GUICtrlRead($generalitem), $GUI_DEFBUTTON) Then GUICtrlSetState($generalitem, 0) GUICtrlSetState($displayitem, 0) Else GUICtrlSetState($generalitem, $GUI_DEFBUTTON) GUICtrlSetState($displayitem, $GUI_DEFBUTTON) EndIf Case $msg = $infobutton $item = GUICtrlRead($treeview) ; Get the controlID of the current selected treeview item If $item = 0 Then MsgBox(64, "TreeView Demo", "No item currently selected") Else $text = GUICtrlRead($item, 1) ; Get the text of the treeview item If $text == "" Then MsgBox(16, "Error", "Error while retrieving infos about item") Else MsgBox(64, "TreeView Demo", "Current item selected is: " & $text); $advmsg[0] contains the text and $advmsg[1] the state value of the treeview item EndIf EndIf Case $msg = $statebutton $item = GUICtrlRead($treeview) If $item > 0 Then $hItem = GUICtrlGetHandle($item) GUICtrlSendMsg($treeview, $TVM_EXPAND, $TVE_TOGGLE, $hItem) EndIf ; The following items will hide the other labels (1st and 2nd parameter) and then show the 'own' labels (3rd and 4th parameter) Case $msg = $generalitem $item = GUICtrlRead($treeview) If $item > 0 Then $hItem = GUICtrlGetHandle($item) $rect1 = _GUICtrlTreeView_DisplayRect($treeview, $hItem) ControlMove($mgGui, "", $cb, $iComboX, $rect1[1], $rect1[2], 16) EndIf GUIChangeItems($aboutlabel, $compinfo, $startlabel, $startlabel) Case $msg = $aboutitem $item = GUICtrlRead($treeview) If $item > 0 Then $hItem = GUICtrlGetHandle($item) $rect1 = _GUICtrlTreeView_DisplayRect($treeview, $hItem) ControlMove($mgGui, "", $cb, $iComboX, $rect1[1], $rect1[2], 16) EndIf GUICtrlSetState($compinfo, $GUI_HIDE) GUIChangeItems($startlabel, $startlabel, $aboutlabel, $aboutlabel) Case $msg = $compitem $item = GUICtrlRead($treeview) If $item > 0 Then $hItem = GUICtrlGetHandle($item) $rect1 = _GUICtrlTreeView_DisplayRect($treeview, $hItem) ControlMove($mgGui, "", $cb, $iComboX, $rect1[1], $rect1[2], 16) EndIf GUIChangeItems($startlabel, $aboutlabel, $compinfo, $compinfo) Case $msg = $resitem Or $msg = $otheritem Or $msg = $useritem $item = GUICtrlRead($treeview) If $item > 0 Then $hItem = GUICtrlGetHandle($item) $rect1 = _GUICtrlTreeView_DisplayRect($treeview, $hItem) ControlMove($mgGui, "", $cb, $iComboX, $rect1[1], $rect1[2], 16) EndIf EndSelect WEnd GUIDelete() EndFunc ;==>Example Func GUIChangeItems($hidestart, $hideend, $showstart, $showend) Local $idx For $idx = $hidestart To $hideend GUICtrlSetState($idx, $GUI_HIDE) Next For $idx = $showstart To $showend GUICtrlSetState($idx, BitOR($GUI_SHOW, $GUI_DISABLE)) Next EndFunc ;==>GUIChangeItems This also uses the current GuiTreeView.au3 UDF _GUICtrlTreeView_DisplayRect() instead of declaring a custom function. >_< Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
lsakizada Posted August 10, 2009 Author Share Posted August 10, 2009 This also uses the current GuiTreeView.au3 UDF _GUICtrlTreeView_DisplayRect() instead of declaring a custom function. >_< Yes, this is exactly what I did. no custom function. This is my code that is works for me (will not run for you..) but popup gui with two buttons (ok, cancel) tthat accept values from combobox. expandcollapse popupFunc _create_popup_hotkey($ComboState) Local $aRect = _GUICtrlTreeView_DisplayRect($treeview, _GUICtrlTreeView_GetSelection($treeview)) Local $tv_pos = ControlGetPos("", "", $treeview) $aRect[0] += $tv_pos[0] $aRect[1] += $tv_pos[1] $wpos = WinGetPos($prog_name, "") $aRect[0] += $wpos[0] $aRect[1] += $wpos[1] GUISetState(@SW_DISABLE, $Form1) $form4 = GUICreate("Select Hotkey", 160, 40, $aRect[0] + 20, $aRect[1] + 25, $WS_POPUP, -1, $Form1) GUISetBkColor(0xFFFFE1, $form4) If $ComboState = 1 Then $input5 = _GUICtrlComboBox_Create($form4, "", 0, 0, 160, 80, BitOR($CBS_DROPDOWN, $WS_VSCROLL)) _GUICtrlComboBox_AddString($input5, "False") _GUICtrlComboBox_AddString($input5, "True") Else $input5 = _GUICtrlComboBox_Create($form4, "", 0, 0, 160, 80, BitOR($CBS_DROPDOWN, $WS_VSCROLL)) For $i = 0 To 115 _GUICtrlComboBox_AddString($input5, $keysArray[$i][1]) Next EndIf GUICtrlSetBkColor(-1, 0xFFFFE1) Local $button_ok = GUICtrlCreateButton("OK", 0, 20, 80, 20) GUICtrlSetBkColor(-1, 0xFFFFE1) Local $button_cancel = GUICtrlCreateButton("Cancel", 80, 20, 80, 20) GUICtrlSetBkColor(-1, 0xFFFFE1) ;$wProcOldLocal = _WinAPI_SetWindowLong(GUICtrlGetHandle($input5), $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle2)) GUISetState(@SW_SHOW, $form4) While 1 If $exit_loop = True Then ExitLoop Local $nMsg = GUIGetMsg() Switch $nMsg Case $button_ok Local $curent = _GUICtrlTreeView_GetSelection($treeview) If Not $ComboState = 1 Then $iIndex = _ArraySearch($keysArray, _GUICtrlComboBox_GetEditText($input5), 0, 0, 0, 0, 1, 1) If @error Then MsgBox(270352, "Error", "Please select one item from the list" & @CRLF & "Please do not type any other value") Else _GUICtrlTreeView_SetText($treeview, $curent, _GUICtrlComboBox_GetEditText($input5)) GUISetState(@SW_ENABLE, $Form1) GUIDelete($form4) $save = False _GUICtrlTreeView_BeginUpdate($treeview) _GUICtrlTreeView_EndEdit($treeview) _GUICtrlTreeView_EndUpdate($treeview) ExitLoop EndIf else Local $TF=_GUICtrlComboBox_GetEditText($input5) If $TF ="False" or $TF="True" Then _GUICtrlTreeView_SetText($treeview, $curent, _GUICtrlComboBox_GetEditText($input5)) GUISetState(@SW_ENABLE, $Form1) GUIDelete($form4) $save = False _GUICtrlTreeView_BeginUpdate($treeview) _GUICtrlTreeView_EndEdit($treeview) _GUICtrlTreeView_EndUpdate($treeview) ExitLoop Else MsgBox(270352, "Error", "Please select one item from the list" & @CRLF & "Please do not type any other value") EndIf EndIf Case $button_cancel GUISetState(@SW_ENABLE, $Form1) GUIDelete($form4) _GUICtrlTreeView_BeginUpdate($treeview) _GUICtrlTreeView_EndEdit($treeview) _GUICtrlTreeView_EndUpdate($treeview) ExitLoop EndSwitch WEnd EndFunc ;==>_create_popup_hotkey Be Green Now or Never (BGNN)! 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