Solved

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

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

820 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