KaFu Posted November 6, 2008 Share Posted November 6, 2008 (edited) HiHo Forum, i have a problem with the GUICtrlSetState() function. If i try to hide a Treeview created with _GUICtrlTreeView_Create() the function won't work. Reason is, that _GUICtrlTreeView_Create() returns a handle and not a control id. I've adjusted the example from the Help-File accordingly. Is this a Bug? And has anyone a workaround for me? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <TreeViewConstants.au3> #include <StaticConstants.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 GUICreate("My GUI with treeview", 350, 215) $treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($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) $aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60) GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "aboutlabel"-text during initialization $compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 120, 30, 200, 80) GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "compinfo"-text during initialization GUICtrlCreateLabel("", 0, 170, 350, 2, $SS_SUNKEN) $togglebutton = GUICtrlCreateButton("&Hide by ID", 35, 185, 100, 20) $infobutton = GUICtrlCreateButton("&Hide by Handle", 135, 185, 100, 20) $cancelbutton = GUICtrlCreateButton("&Show", 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 GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $cancelbutton GUICtrlSetState($treeview,$GUI_SHOW) case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $togglebutton GUICtrlSetState($treeview,$GUI_HIDE) Case $msg = $infobutton GUICtrlSetState(GUICtrlGetHandle($treeview),$GUI_HIDE) EndSelect WEnd GUIDelete() EndFunc ;==>Example Best Regards Edited November 10, 2008 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
rover Posted November 6, 2008 Share Posted November 6, 2008 HiHo Forum, i have a problem with the GUICtrlSetState() function. If i try to hide a Treeview created with _GUICtrlTreeView_Create() the function won't work. Reason is, that _GUICtrlTreeView_Create() returns a handle and not a control id. I've adjusted the example from the Help-File accordingly. Is this a Bug? And has anyone a workaround for me? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <TreeViewConstants.au3> #include <StaticConstants.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 GUICreate("My GUI with treeview", 350, 215) $treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($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) $aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60) GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "aboutlabel"-text during initialization $compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 120, 30, 200, 80) GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "compinfo"-text during initialization GUICtrlCreateLabel("", 0, 170, 350, 2, $SS_SUNKEN) $togglebutton = GUICtrlCreateButton("&Hide by ID", 35, 185, 100, 20) $infobutton = GUICtrlCreateButton("&Hide by Handle", 135, 185, 100, 20) $cancelbutton = GUICtrlCreateButton("&Show", 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 GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $cancelbutton GUICtrlSetState($treeview,$GUI_SHOW) case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $togglebutton GUICtrlSetState($treeview,$GUI_HIDE) Case $msg = $infobutton GUICtrlSetState(GUICtrlGetHandle($treeview),$GUI_HIDE) EndSelect WEnd GUIDelete() EndFunc ;==>ExampleoÝ÷ جµ j·lþ«¨µá +k'JÖ{ +Ì"¶(Úè÷öÊ'&®¶sb4æ6ÇVFRfÇCµväæS2fwC°¥õväõ6÷uvæF÷ruT7G&ÄvWDæFÆRb33c·G&VWfWrÂ5uôDR I see fascists... Link to comment Share on other sites More sharing options...
KaFu Posted November 6, 2008 Author Share Posted November 6, 2008 GUICtrlSetState() works with control ID's only #Include <WinAPI.au3> _WinAPI_ShowWindow(GUICtrlGetHandle($treeview), @SW_HIDE) Thanks for the reply and work-around... Best Regards OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) 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