Sign in to follow this  
Followers 0
Qsr Nrwn

Number of controls on a GUI

3 posts in this topic

#1 ·  Posted (edited)

Well, this is perhaps my most-stupid question... I need to count the number of controls present at a given time in a GUI.

Is there a way to acomplish that? Just point me to the way... I will go and fish it.

The setting is that I use variable lenght text-files to load TreeViewControls, and some of them have context menus. Because the documentation I know that AutoIt has a limit of 4095 controls per GUI. I want to avoid this, by catching this error before it happens and Pandora's box opens...

Thanks in advance

EDIT: Clarification

Edited by Qsr Nrwn

Rev 127 Et factum et prælium magnum in cælo: Michaël et angeli ejus præliabantur cum dracone, et draco pugnabat, et angeli ejus: 8 et non valuerant, neque locus inventus est eorum amplius in cælo.9 Et projectus est draco ille magnus, serpens antiquus, qui vocatur diabolus, et Satanas, qui seducit universum orbem: et projectus est in terram, et angeli ejus cum illo missi sunt.

Share this post


Link to post
Share on other sites



$Scintilla = _ControlGetCount('', 'Scintilla')
$All = _ControlGetCount('')
MsgBox(0, '', 'Scintilla: ' & $Scintilla & @CRLF & 'All: ' & $All)

Func _ControlGetCount($hWndGUI, $sType = '')
    If $sType = '' Then _
        Return UBound(StringSplit(StringTrimRight(WinGetClassList($hWndGUI), 1), @LF)) - 1
    For $iCC = 1 To 4095
        If ControlGetHandle($hWndGUI, '', $sType & $iCC) = 0 Then Return $iCC - 1
    Next
    Return SetError(1, 0, '')
EndFunc


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thanks SmOke_N, I run out of ideas...


Rev 127 Et factum et prælium magnum in cælo: Michaël et angeli ejus præliabantur cum dracone, et draco pugnabat, et angeli ejus: 8 et non valuerant, neque locus inventus est eorum amplius in cælo.9 Et projectus est draco ille magnus, serpens antiquus, qui vocatur diabolus, et Satanas, qui seducit universum orbem: et projectus est in terram, et angeli ejus cum illo missi sunt.

Share this post


Link to post
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
Sign in to follow this  
Followers 0