Solved

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

Posted on 2004-04-20
3
1,317 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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 tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

914 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

19 Experts available now in Live!

Get 1:1 Help Now