Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 20: List-Based Controls Visual C++ and MFC Fundamentals



  1. To declare and associate a variable for a control, right-click the Container combo
    box and click Add Variable

  2. In the Category combo box, select Value

  3. In the Variable Type combo box, select int

  4. In the Variable Name, type m_ContainerValue

  5. Click Finish

  6. On the dialog box, right-click the Flavor combo box and click Add Variable

  7. In the Category combo box, accept the Control selected. In the Variable Name, type
    m_Flavors and press Enter

  8. Add the following variables for the other controls (all the Value Variables are
    CString type):


ID Control Variable Value Variable
IDC_TOPPING m_Topping
IDC_SCOOPS m_Scoops
IDC_TAX_RATE m_TaxRate
IDC_SUB_TOTAL m_SubTotal
IDC_TAX_AMOUNT m_TaxAmount
IDC_ORDER_TOTAL m_OrderTotal


  1. Save All


20.2.3..Combo Box Methods..........................................................................


A combo box is based on the CComboBox class. Therefore, if you want to dynamically
create this control, declare a variable or a pointer to CComboBox using its default
constructor. To initialize the control, call its Create() method. Here is an example:

BOOL CExerciseDlg::OnInitDialog()
{
CDialog::OnInitDialog();

SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
Free download pdf