OmYcroN Posted April 11, 2009 Share Posted April 11, 2009 _GUICtrlTreeView_Add() is returning "The handle to the new item" and i need it to return the ID of the new item. I can't use the handle in an switch GuiGetMsg() case ... or can i ? And if i can use the handles in that switch case how can i manage an array of handles like let's say $handles[10] (case $handles[0] to $handles[9]) Link to comment Share on other sites More sharing options...
Valuater Posted April 11, 2009 Share Posted April 11, 2009 _GUICtrlTreeView_Add() is returning "The handle to the new item" and i need it to return the ID of the new item. I can't use the handle in an switch GuiGetMsg() case ... or can i ? And if i can use the handles in that switch case how can i manage an array of handles like let's say $handles[10] (case $handles[0] to $handles[9]) #1 With a TreeView you don't need to place the ID in a variable, just use _GUICtrlTreeView_GetSelection($hTreeView)) #2 to "Loop" through an array of Control ID's $msg = GUIGetMsg() For $x = 1 To UBound($Control_ID) - 1 If $msg = $Control_ID[$x] Then ; Do something Next 8) Link to comment Share on other sites More sharing options...
OmYcroN Posted April 11, 2009 Author Share Posted April 11, 2009 I need the id s in order to expand/collapse the elements of the tree. I'm reading some folders and subfolders dynamically and i want to assign them to the tree elements. For example i have Folder01->Subfolder01, Subfolder02 so the tree will look like this : +Folder01 |--- Subfolder01 |--- Subfolder02 .... and when i check Folder01 i want them to expand/collapse but for that in an switch case i need their IDs. That function is returning me the handles of them and not their IDs. I'll have 2 arrays $folders[n] and $subfolders[n] and in the switch case something like this : case $folders[0] to $folders[n - 1] controlTree(GuiGetMsg()) ; used to collapse/expand the Folder01 or others Link to comment Share on other sites More sharing options...
isolation Posted April 11, 2009 Share Posted April 11, 2009 _GUICtrlTreeView_AddChild why do you want to collapse/expand it manually or _GUICtrlTreeView_GetSelection Link to comment Share on other sites More sharing options...
OmYcroN Posted April 11, 2009 Author Share Posted April 11, 2009 _GUICtrlTreeView_AddChildwhy do you want to collapse/expand it manuallyor_GUICtrlTreeView_GetSelectionAll the elemnts in the tree have checkboxes (sorry if i forgot) and when selecting folder01 i need the subfolders01, 02 to collapse/expand cause that control isn t automatic Link to comment Share on other sites More sharing options...
isolation Posted April 11, 2009 Share Posted April 11, 2009 _GUICtrlTreeView_GetChecked I think Link to comment Share on other sites More sharing options...
OmYcroN Posted April 11, 2009 Author Share Posted April 11, 2009 (edited) _GUICtrlTreeView_GetChecked I think That checks if that selected. This is how i want it to work : So I create those elements by using _GUICtrlTreeView_Add for folders and _GUICtrlTreeView_AddChild for subfolders and in the switch statement i want to use a function to colapse/expand those created with _GUICtrlTreeView_AddChild but that returns a handle ($folders[$i] = _GUICtrlTreeView_AddChild( ... )) so in case $folders[0] to $folders[n - 1] the function is used automatically when running the script (why is that ?!) ... so i need their IDs to beeter handle them. I thinK the main question would be here HOW CAN I GET THE ID OF AN ITEM THAT HAS A HANDLE VALUE ? Edited April 11, 2009 by OmYcroN Link to comment Share on other sites More sharing options...
Valuater Posted April 11, 2009 Share Posted April 11, 2009 Maybe this can help Run ("calc.exe" ) WinWait( "Calculator" ) $hwnd = ControlGetHandle( "Calculator", "", "[TEXT:2]" ) $id = GetControlID( $hwnd ); <---- this gets the control ID of the "2" button ControlClick ("Calculator", "", $id ) Func GetControlID( $hwnd) Local $ID = DllCall('user32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hwnd) if IsArray ($ID) Then Return $ID[0] Return 0 EndFunc 8) BTW, I hate guessing games Link to comment Share on other sites More sharing options...
OmYcroN Posted April 11, 2009 Author Share Posted April 11, 2009 Maybe this can help Run ("calc.exe" ) WinWait( "Calculator" ) $hwnd = ControlGetHandle( "Calculator", "", "[TEXT:2]" ) $id = GetControlID( $hwnd ); <---- this gets the control ID of the "2" button ControlClick ("Calculator", "", $id ) Func GetControlID( $hwnd) Local $ID = DllCall('user32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hwnd) if IsArray ($ID) Then Return $ID[0] Return 0 EndFunc 8) BTW, I hate guessing games This function seems correct but it returns only $ID[0] = 0 (the handle param it s ok, returning array in this function, so everything seems ok but the value is always 0 ... why is that ? ). The param for this func used by me is that of _GUICtrlTreeView_Add() witch returns for ex 0x00834132 ... so it s seems alright here too ... 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