Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

antiMATTER

populating a combo box on a dialog box created in Visual C++ 6

This topic is 5237 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

How would I add/delete text to/from a combo box that I''ve placed on a dialog box in Visual C++ 6? I''m thinking I need to send a message to the comb box with additions and deletions but I don''t know if this is how it''s done or what function would do this. thanks

Share this post


Link to post
Share on other sites
Advertisement
To add text to a combo box, you can use the SendMessage() function with the handle of the combo box. The CB_ADDSTRING message can be used to add text, and CB_DELETESTRING message can be used to remove text. Depending on how you created the dialog, you might be able to use the GetDlgItem() function to get the combo box''s handle.

Share this post


Link to post
Share on other sites
Thanks for the quick replies.

This is what I''m trying but it doesn''t work. Any ideas?

SendMessage(GetDlgItem(models->getHandle(),IDC_MODELS_COMBO),CB_ADDSTRING,0,(LPARAM) "test");

Share this post


Link to post
Share on other sites
Well, first I would split the call into separate lines. Check to make sure that the call to GetDlgItem() is returning non-NULL. If it is NULL check GetLastError() for an error code. Then check the return value of SendMessage() to see if it''s returning CB_ERR or CB_ERRSPACE.

Share this post


Link to post
Share on other sites
It''s working. My bad. My combo boxes drop down list wasn''t pulled down in the resource editor. So when I was checking for values in the drop down list I wasn''t seeing anything.

THANKS!

Share this post


Link to post
Share on other sites
ok... let''s elaborate a bit on this. I''m now able to add and delete values. How do I tell which value is the current selected value? How would I delete the current selected value? Right now when I delete it just deletes the item at the top of the list, which is sorted in alphabetical order.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!