dinodod Posted February 6, 2007 Share Posted February 6, 2007 Is there a function or UDF alrady made that can count the total number of controls on page? I have a dynamic menu system but in my Case statement, I need to know the number of controls on the GUI so I can properly loop thru each item. I have a mix of controls so a counter variable is not possible. Thanks! Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007 Link to comment Share on other sites More sharing options...
herewasplato Posted February 6, 2007 Share Posted February 6, 2007 I'm not sure that I understand all that you are after - so forgive me if this link is not what you are looking for:http://www.autoitscript.com/forum/index.ph...showtopic=32077-MSP- [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 6, 2007 Moderators Share Posted February 6, 2007 http://www.autoitscript.com/forum/index.ph...st&p=301124 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. Link to comment Share on other sites More sharing options...
herewasplato Posted February 6, 2007 Share Posted February 6, 2007 http://www.autoitscript.com/forum/index.ph...st&p=301124...silly me, I searched the example scripts - while your fine handywork was hiding in the support forum. :-) [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
dinodod Posted February 6, 2007 Author Share Posted February 6, 2007 (edited) I'm not sure that I understand all that you are after - so forgive me if this link is not what you are looking for: http://www.autoitscript.com/forum/index.ph...showtopic=32077 -MSP- Smokin, as always. Many thanks. HerewasPlato, thanks for your help too I guess I'm not seeing this one. I've used your code and I'm not getting the correct number of controls being sent back to me. I've looked up WinGetClassList (in the autoit help file) and it doesn't quite make sense to me. It's also 2:30 a.m. here as well. Thoughts? expandcollapse popup#include <GuiConstants.au3> #include <GuiTreeView.au3> #include <SQLite.au3> #include <sqlite.dll.au3> #include <Array.au3> #Include <File.au3> $DBList=_FileListToArray(@scriptdir & "\databases") GuiCreate("SQL DB Manager", 392, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $Treeview = GuiCtrlCreateTreeview(60, 60, 130, 200) $TreeItem_Databases = GUICtrlCreateTreeViewitem("Databases", $Treeview) Func_ListDB() $TreeItem_Queries = GUICtrlCreateTreeViewitem("Queries", $Treeview) GUICtrlSetColor(-1, 0x0000C0) ; Content Menu $DatabaseContent = GUICtrlCreateContextMenu($TreeItem_Databases) $menuItem_NewDB = GUICtrlCreateMenuitem ("New", $DatabaseContent) GUICtrlCreateMenuitem ("", $DatabaseContent) ; separator $menuItem_OpenDB = GUICtrlCreateMenuitem ("Open", $DatabaseContent) $Scintilla = _ControlGetCount('', '') $All = _ControlGetCount("SQL DB Manager","") 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 Func Func_ListDB() For $x = 1 to $DBList[0] $SubTreeItem_Databases = GUICtrlCreateTreeViewitem($DBList[$x], $TreeItem_Databases) next EndFunc Edited February 6, 2007 by dinodod Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 6, 2007 Moderators Share Posted February 6, 2007 I'm curious... what do you expect the return to be? You don't expect it to return the menus and tree view items do you? 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. Link to comment Share on other sites More sharing options...
dinodod Posted February 6, 2007 Author Share Posted February 6, 2007 Actually, I am. I have a need to generate a loop to see every control in the gui that is visible. But then a loop from 1 to 4095 (max number of controls in a GUI from what i read), doesn't appear to be bad yet. The reason is because I am tweaking my Dynamic Menu code and rather than guess at the number of controls, I was thinking it could be easier to perform a count. In larger scenarios, a loop from 1 to 4095 coul slow the system down. However, I think I have a workaround that might just work. It involves creating an array to hold some values. I hope to finish the code tonight and post it in the Example Code section. If it works well, I plan on making a couple of different types in order to support treeview menus as well as menubars, etc. Cross your fingers. Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007 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