Chapter 20: List-Based Controls Visual C++ and MFC Fundamentals
- To declare and associate a variable for a control, right-click the Container combo
box and click Add Variable - In the Category combo box, select Value
- In the Variable Type combo box, select int
- In the Variable Name, type m_ContainerValue
- Click Finish
- On the dialog box, right-click the Flavor combo box and click Add Variable
- In the Category combo box, accept the Control selected. In the Variable Name, type
m_Flavors and press Enter - 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
- 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