Archived

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

MFC ComboBox probs

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

Hey, I am working on a level editor and I am having some problems with ComboBoxs. The first thing I do is retrieve it from the dialog that it is in(created in MSVC dialog editor). m_pCBObjectType = (CComboBox*) m_RBar.GetDlgItem (IDC_NEWOBJECT_TYPE); I then use AddString to add four strings. m_pCBObjectType->AddString("Box"); m_pCBObjectType->AddString("Triangle"); m_pCBObjectType->AddString("Sphere"); m_pCBObjectType->AddString("Cone"); According to my bookon MFC this should work. Is there something that I have to do to display it? Thanks. InFerN0 Not all who wander are lost...

Share this post


Link to post
Share on other sites
Hmm. Your wording is a bit cryptic. Do you mean that you can''t see the combo box or that you can''t see the added strings?

For that matter, if you''re using the editor anyway, and the strings you''re using are fixed (they''re the only things you''re going to display), why not just right click on the combobox in the editor, go to "Properties", hit the "Data" tab, and enter your strings there and not go to the hassle?

It''s also possible that you aren''t seeing the strings because you haven''t expanded the dropdown list size sufficiently to see it, in which case click the down arrow over on the right. You will see the extents of the dropdown list. Resize it appropriately.

-fel

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hmm...

Can you do any other operations to the combo box?

What about using the Class Wizard to map a variable to the Control. e.g. set a variable m_comboboxobj to point to IDC_NEWOBJECT_TYPE.

Then from your code you could just use
m_comboboxobj.AddString(char*);

????

Share this post


Link to post
Share on other sites
Oops - forgot to put my name on that last post.

And I meant to say you could just
m_comboboxobj.AddString(char*);
instead of having to retrieve the DlgItem first.

E

Edited by - Eight on March 16, 2001 1:23:18 PM

Share this post


Link to post
Share on other sites
A common mistake with combo boxes (i''m not sure if this is your problem... slightly cryptic):

When you create the combo box in the Dialog Edior, you must drag it out in size so that it''s height WILL BE HOW FAR IT DROPS DOWN. Otherwise when you click it nothing happens. So in other words, when you place a combo box, drag a square, not a thin rectangle, and it should work.

You can also edit the strings in the dialog editor... but i don''t know if you can access the string tables from there ...?

Share this post


Link to post
Share on other sites
Hey,
Thanks for the replies. To be more specific the box looks like it drops down but it never creates a rect below the control to put the strings in. Thanks. BTW. I can make a new combo box and it works but if I use the same ID it doesn''t.

InFerN0

Not all who wander are lost...

Share this post


Link to post
Share on other sites
Yes, all objects in MFC (apart from static text) must have different ID numbers, or else it wont work.

If you have an existing combo box that is an incorrect size, simply click it, and drag it downwards in size. You will see what I mean once in the Resource editor...

Share this post


Link to post
Share on other sites
To change the pull down boxes size for a combo box, click on the button in resource editor. By button I mean the actual button you would normally click on, if you were using the GUI.

The resource editor will then allow you to manipulate the pull down box vs. the actual combo box itself.

Share this post


Link to post
Share on other sites