Solved

Combo Box Controls

Posted on 2002-03-22
5
255 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
Comment Utility

    // 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
Comment Utility
0
 

Expert Comment

by:GEliyahu
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you very much.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

728 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

14 Experts available now in Live!

Get 1:1 Help Now