Solved

Combo Box Controls

Posted on 2002-03-22
5
278 Views
Last Modified: 2010-04-02
Hello experts...

I am about to use a combo box in a dialog box by first time...

I guess I have to initialize this control in the WM_INITDIALOG message....

But can anyone tell the combo box works?

I mean.... Adding items... find out what item is selected... etc...

Thanks.


0
Comment
Question by:Marsc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
thienpnguyen earned 100 total points
ID: 6889437

    // Add the string to the combo box
    SendMessage( hCombo, CB_ADDSTRING,  0, (LPARAM) (LPCTSTR) strDesc );

    // Select the first device in the combo box
    SendMessage( hCombo, CB_SETCURSEL, 0, 0 );
   
    // Get the index of the currently selected devices
    INT nIndex = (INT)SendMessage( hCombo, CB_GETCURSEL, 0, 0 );

   
    // retrieve the number of items in the list box of a combo box.
    INT numItem = (INT)SendMessage( hCombo, CB_GETCOUNT, 0, 0 );

   
0
 

Expert Comment

by:GEliyahu
ID: 6893730
Here is the way to add an items to a CComboBox:

first build the control using the "window controls",by add the control to your dialog.

now when you have a CComboBox control on your CDialog you should press the right mouse on the combo control-->Properties-->Data-->(Add a text)-->press CTRL+RETURN

this is the easiest to add a text to your CComboBox.

GEliyahu.
0
 
LVL 1

Author Comment

by:Marsc
ID: 6896632
GEliyahu:

Thank you for your answer.... But I need to add items in run time.
In "design" times I have no way to know wich the items are...

0
 
LVL 1

Author Comment

by:Marsc
ID: 6896640
Thank you very much.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
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 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 learn how to clear a vector as well as how to detect empty vectors in C++.

623 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