OmYcroN Posted April 24, 2009 Share Posted April 24, 2009 I don't understand what's happening here : $hTreeView = _GUICtrlTreeView_Create( ... no need for this ... ) ; this returns the handle (something like 0x002a0428) _WinAPI_GetDlgCtrlID(-1 or hTreeView) ; this results always 0x00000000 Why ? Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 24, 2009 Share Posted April 24, 2009 I don't understand what's happening here : $hTreeView = _GUICtrlTreeView_Create( ... no need for this ... ) ; this returns the handle (something like 0x002a0428) _WinAPI_GetDlgCtrlID(-1 or hTreeView) ; this results always 0x00000000 Why ? From the help file: Remarks GetDlgCtrlID accepts child window handles as well as handles of controls in dialog boxes. An application sets the identifier for a child window when it creates the window by assigning the identifier value to the hmenu parameter when calling the CreateWindow or CreateWindowEx function. Although GetDlgCtrlID may return a value if $hWnd identifies a top-level window, top-level windows cannot have identifiers and such a return value is never valid. Is this a pop up dialog or child window? 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...
OmYcroN Posted April 24, 2009 Author Share Posted April 24, 2009 From the help file: Is this a pop up dialog or child window? $hGUI = GUICreate("Title", 100, 100) ; thats all Link to comment Share on other sites More sharing options...
KaFu Posted April 24, 2009 Share Posted April 24, 2009 MsgBox(0,"","Handle: " & $hTreeView & @crlf & "ControlID: " & number(_WinAPI_GetDlgCtrlID($hTreeView)) & @crlf) returns ControlID for me if applied to _GUICtrlTreeView_Create() example in help-file. 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...
martin Posted April 24, 2009 Share Posted April 24, 2009 From the help file: Is this a pop up dialog or child window? The $hWnd refers to the treeview control not the parent gui so it's not a top-level window. 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...
martin Posted April 24, 2009 Share Posted April 24, 2009 (edited) I don't understand what's happening here : $hTreeView = _GUICtrlTreeView_Create( ... no need for this ... ) ; this returns the handle (something like 0x002a0428) _WinAPI_GetDlgCtrlID(-1 or hTreeView) ; this results always 0x00000000 Why ? I think the answer is, as Kafu implies, that you are simply wrong. Try this expandcollapse popup#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) $Debug_TV = False; Check ClassName being passed to functions, set to True and use a handle to another control to see it work Global $hTreeView _Main() Func _Main() Local $GUI Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) $GUI = GUICreate("(UDF Created) TreeView Create", 400, 300) $hTreeView = _GUICtrlTreeView_CreateB($GUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) GUISetState() consolewrite(_WinAPI_GetDlgCtrlID($hTreeView) & @CR) EndFunc ;==>_Main Func _GUICtrlTreeView_CreateB($hWnd, $iX, $iY, $iWidth = 150, $iHeight = 150, $iStyle = 0x00000037, $iExStyle = 0x00000000) If Not IsHWnd($hWnd) Then _WinAPI_ShowError("Invalid Window handle for _GUICtrlTreeView_Create 1st parameter") Local $hTree, $nCtrlID If $iWidth = -1 Then $iWidth = 150 If $iHeight = -1 Then $iHeight = 150 If $iStyle = -1 Then $iStyle = 0x00000037 If $iExStyle = -1 Then $iExStyle = 0x00000000 $iStyle = BitOR($iStyle, $__TREEVIEWCONSTANT_WS_CHILD, $__TREEVIEWCONSTANT_WS_VISIBLE) $nCtrlID = _UDF_GetNextGlobalID($hWnd) ConsoleWrite("id = " & Hex($nCtrlID) & @CRLF) If @error Then Return SetError(@error, @extended, 0) $hTree = _WinAPI_CreateWindowEx($iExStyle, $__TREEVIEWCONSTANT_ClassName, "", $iStyle, $iX, $iY, $iWidth, $iHeight, $hWnd, $nCtrlID) _WinAPI_SetFont($hTree, _WinAPI_GetStockObject($__TREEVIEWCONSTANT_DEFAULT_GUI_FONT)) _GUICtrlTreeView_SetUnicodeFormat($hTree, False) Return $hTree EndFunc ;==>_GUICtrlTreeView_Create Edited April 24, 2009 by martin 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...
OmYcroN Posted April 24, 2009 Author Share Posted April 24, 2009 MsgBox(0,"","Handle: " & $hTreeView & @crlf & "ControlID: " & number(_WinAPI_GetDlgCtrlID($hTreeView)) & @crlf) returns ControlID for me if applied to _GUICtrlTreeView_Create() example in help-file. Im sorry ... i wanted to refer to $parent = _GUICtrlTreeView_Add($hTreeView, ... ). This one does return that 0x00000000 for _WinAPI_GetDlgCtrlID($parent) Link to comment Share on other sites More sharing options...
KaFu Posted April 24, 2009 Share Posted April 24, 2009 (edited) This creates an item in the treeviews SysTreeView32 control, which as far as I know does not have a controlId of its own but is accessed via the returned handle only. What operation do you want to perform, that you try to obtain a controlID? All operations can be performed using the handle. Edited April 24, 2009 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...
OmYcroN Posted April 24, 2009 Author Share Posted April 24, 2009 This creates an item in the treeviews SysTreeView32 control, which as far as I know does not have a controlId of its own but is accessed via the returned handle only.What operation do you want to perform, that you try to obtain a controlID? All operations can be performed using the handle.For example i have a treeview with 4 $parents each with 2 $childs and i want to know what $child was checked (i have that style for the tree) $parent02 $child0101 $child0102$parent02 $child0201 $child0202How can i do that using GUIGetMsg() cause with id s is really simple but with handles i don't understand how. Link to comment Share on other sites More sharing options...
KaFu Posted April 24, 2009 Share Posted April 24, 2009 (edited) Use _GUICtrlTreeView_GetFirstItem() amd _GUICtrlTreeView_GetNext() to loop through items and check state like you would do it with FileFindFirstFile() and FileFindNextFile() for files. Edit: Resp. _GUICtrlTreeView_GetFirstChild() _GUICtrlTreeView_GetNextChild() for child items. Edited April 24, 2009 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...
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