Solved

Can't get combobox to work (Visual C++ 6)

Posted on 2004-04-20
3
1,316 Views
Last Modified: 2008-01-09
Hi,

All I'm trying to do is get my combobox (id IDC_COMBO1) to display stuff at runtime.

In OnInitDialog I've got
CComboBox* pcmb = (CComboBox*)GetDlgItem(IDC_COMBO1);
pcmb->AddString("ABC");

Is this right? If so, why doesn't it work? I also tryed just writing some stuff in the data section of the combobox properties, but that didn't work either. It's a Drop List, but nothing happens when I run it and click on the arrow. I also tried creating a CComboBox variable in the ClassWizard, but couldn't get this to work either.

I'm sure it's something extremely simple, but I haven't used a combobox before,

Thanks
0
Comment
Question by:shifty_mc
3 Comments
 
LVL 3

Accepted Solution

by:
akalmani earned 55 total points
ID: 10867938
1) In the resource editor check the combobox properties, see if visible is checked.
2) In the resource editor click on the combo box droplist arrow (down arrow) and see if the height is ok. I mean increase the height of the data area of combo box.
3) Check whether the ID of the combo box is right?

You can as well statically add some data in the resource editor. Just click of the data and add values. If you need more than 1 just press Ctrl+Enter instead of just enter.
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 10867959
That should work, but maybe you have to call

    UpdateData(FALSE)

to invoke a screen refresh.

If you still see nothing in the box,  most likely the ID is wrong or you have two comboboxes one hiding the other.

You may post the dialog header file, the OnInitDialog function and the .rc file then.

Regards, Alex
0
 

Author Comment

by:shifty_mc
ID: 10868068
Ah, it was just the height thing - thank you very much. I knew I was doing the code right, but I didn't know about the data area height and didn't come across it in any of my searches,

Thanks again.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now