Solved

Combo Box Controls

Posted on 2002-03-22
5
264 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
  • 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
 
LVL 6

Expert Comment

by:thienpnguyen
ID: 6889444
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

809 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