tailieunhanh - Visual C++ and MFC Fundamentals programming phần 10
Để khai báo và kết hợp một biến để kiểm soát, phải nhấp vào hộp kết hợp container và nhấn vào Add Variable Trong hộp kết hợp loại, chọn giá trị Trong hộp kết hợp Loại biến, chọn int Tên biến, loại m_ContainerValue Kích Finish Trên hộp thoại, nhấp vào hộp kết hợp hương vị và click Add Variable | Chapter 20 List-Based Controls Visual C and MFC Fundamentals 4. To declare and associate a variable for a control right-click the Container combo box and click Add Variable 5. In the Category combo box select Value 6. In the Variable Type combo box select int 7. In the Variable Name type m_ContainerValue 8. Click Finish 9. On the dialog box right-click the Flavor combo box and click Add Variable 10. In the Category combo box accept the Control selected. In the Variable Name type m_Flavors and press Enter 11. 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 12. Save All 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 SetIcon m_hIcon FALSE Set big icon Set small icon 654 FunctionX Inc. Visual C and MFC Fundamentals Chapter 20 List-Based Controls TODO Add extra initialization here CComboBox Majors new CComboBox Majors- Create WS_CHILD WS_VISIBLE WS_VSCRoLl CBS_DROpDoWNLIST CRect 10 50 100 150 this 0x1448 return TRUE return TRUE unless you set the focus to a control After creating the control probably the next action to take consists of creating its items. To add a string to a combo box you can call the CComboBox AddString method that uses the same syntax as the CListBox AddString member function. Here is an example BOOL CExerciseDlg OnInitDialog CDialog OnInitDialog SetIcon m_hIcon TRUE Set big icon SetIcon m_hIcon FALSE Set small icon TODO Add extra initialization here CComboBox Majors new CComboBox Majors- Create WS_CHILD WS_VISIBLE ws_vscroLl .
đang nạp các trang xem trước