Sign in to follow this  

Retrieving items from a drop-down menu?

This topic is 4612 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Lets say for example that I have a calculator program. This program has a drop down with "Multiply", and "Divide" in it. How would I retrieve which one is selected in the drop down? This is in C++ and Win32.

Share this post


Link to post
Share on other sites
I still cannot figure out how to use CB_GETCURSEL. The MSDN site doesn't really help me a whole lot.

Share this post


Link to post
Share on other sites
Quote:
Original post by kelcharge
I still cannot figure out how to use CB_GETCURSEL. The MSDN site doesn't really help me a whole lot.


int index = (int)::SendMessage(hwnd, CB_GETCURSEL, 0, 0);

where "hwnd" is the handle to the ComboBox.

The index corresponds to whichever string is selected in your combo box.

Multiply = 0
Divide = 1

That's how you'd know which one was selected.



Share this post


Link to post
Share on other sites
There's also a macro called ComboBox_GetCurSel() defined in the header <windowsx.h>, for example:

int selectedIndex = ComboBox_GetCurSel(hwndComboBox);

Share this post


Link to post
Share on other sites

This topic is 4612 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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