Jump to content
Sign in to follow this  
mcdell

Question about ComboBox

Recommended Posts

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

Share this post


Link to post
Share on other sites

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 by mcdell

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

Sorry about stupid answer, I shouldn't do it too late... :lmao:

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.

Share this post


Link to post
Share on other sites

Sorry about stupid answer, I shouldn't do it too late...  :lmao:

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 o:) 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 by mcdell

Share this post


Link to post
Share on other sites

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

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...