Jump to content

Handles and IDs


Recommended Posts

_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

_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)

NEWHeader1.png

Link to comment
Share on other sites

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

_GUICtrlTreeView_AddChild

why do you want to collapse/expand it manually

or

_GUICtrlTreeView_GetSelection

All 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

_GUICtrlTreeView_GetChecked

I think

That checks if that selected.

This is how i want it to work :

post-33427-1239471030_thumb.png

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 by OmYcroN
Link to comment
Share on other sites

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

NEWHeader1.png

Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...