mcdell Posted February 26, 2005 Share Posted February 26, 2005 Hi, How do you get the number of items in a ComboBox? Say for example you open My Computer and when you click on the button that has an arrow point down, a list of things appear, such as you cd rom and control panel. How do you get the total number of items under that list? Thanks Link to comment Share on other sites More sharing options...
buzz44 Posted February 26, 2005 Share Posted February 26, 2005 a windows combo box like in my computer or a GUICtrlCreateCombo? qq Link to comment Share on other sites More sharing options...
mcdell Posted February 26, 2005 Author Share Posted February 26, 2005 (edited) a windows combo box like in my computer or a GUICtrlCreateCombo?<{POST_SNAPBACK}>The window (like my computer) combo box, what I am trying to do is to find the number of items in a combo box so I will end up selecting each item and run the application with that setting. Edited February 26, 2005 by mcdell Link to comment Share on other sites More sharing options...
Lazycat Posted February 26, 2005 Share Posted February 26, 2005 You can use GUICtrlSendMsg function to get items count: $CB_GETCOUNT= 0x0146 $count = GUICtrlSendMsg($hCombo, $CB_GETCOUNT, 0, 0) Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
mcdell Posted February 26, 2005 Author Share Posted February 26, 2005 You can use GUICtrlSendMsg function to get items count:$CB_GETCOUNT= 0x0146 $count = GUICtrlSendMsg($hCombo, $CB_GETCOUNT, 0, 0)<{POST_SNAPBACK}>How about for a Winsows combo box? Link to comment Share on other sites More sharing options...
Lazycat Posted February 26, 2005 Share Posted February 26, 2005 Sorry about stupid answer, I shouldn't do it too late... Anyway, you can try something like: $hcWnd = ControlGetHandle ("Total Commander", "", "TComboBox1") $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $hcWnd, "int", 0x0146, "int", 0, "int", 0) MsgBox (0, "Count", $ret[0]) Unfortunately, this not works with explorer combos, probably they are non-standard controls. But with many other programs this should work (tested with Total Commander). Maybe someone knows explorer solution. Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
mcdell Posted February 26, 2005 Author Share Posted February 26, 2005 (edited) Sorry about stupid answer, I shouldn't do it too late... Anyway, you can try something like:$hcWnd = ControlGetHandle ("Total Commander", "", "TComboBox1") $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $hcWnd, "int", 0x0146, "int", 0, "int", 0) MsgBox (0, "Count", $ret[0])Unfortunately, this not works with explorer combos, probably they are non-standard controls. But with many other programs this should work (tested with Total Commander). Maybe someone knows explorer solution.<{POST_SNAPBACK}>It worked However do you know where can I find the prototype for this function? What are the 0x0146 and the two 0's mean? Also, you know to use 0146 to get the number of items, what if I want to get other properties? Where can I find the message codes?Thanks Edited February 27, 2005 by mcdell Link to comment Share on other sites More sharing options...
Lazycat Posted February 27, 2005 Share Posted February 27, 2005 First place - MSDN Library, with detailed info about any API function or constant. For quick reference I recommend API Viewer 2004 - database with (probably) all constants and functions. Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
juk Posted July 6, 2005 Share Posted July 6, 2005 Sorry about stupid answer, I shouldn't do it too late... Anyway, you can try something like:$hcWnd = ControlGetHandle ("Total Commander", "", "TComboBox1") $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $hcWnd, "int", 0x0146, "int", 0, "int", 0) MsgBox (0, "Count", $ret[0])Unfortunately, this not works with explorer combos, probably they are non-standard controls. But with many other programs this should work (tested with Total Commander). Maybe someone knows explorer solution.<{POST_SNAPBACK}>That worked with explorer, tho not every time. I checked MSDN and API viewer, but couldn't find a list of the message-codes, like that 0x0146 for count. I'm trying to get the elements in a combobox to an array (or string, if there's another code to go through the list in the combo). I'd appreciate any help!-juk 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