First, create a dialog box-based MFC application!
1. Add combo box controls and control variables
Drag the toolbox to the resource dialog box! ID: idc_combo_web
Note: adjust the height of the pull down item. Otherwise, only one row is displayed!
You cannot adjust the height directly. You need to click the blue area of the Down Arrow to drag the height! (Eight hollow boxes marked in the direction, which is solid in the bottom ...)
In the resource dialog box, right-click the control ---> [add variable] and enter the variable name m_cbwebs!
2. Add item)
M_cbwebs.addstring ("www.baidu.com"); <br/> m_cbwebs.addstring ("www.baidu.com. SB "); <br/> m_cbwebs.addstring (" www.google.com.hk "); <br/> // The above code is generally added to the initialization of the dialog box, that is, oninitdialog ()
3. Add a cbn_selchange message response. When an item is selected, the message event is triggered.
Resource dialog box, combo box control (idc_combo_web) ---> [attribute],
In the lightning icon [control event], click cbn_selchange. The oncbnselchangecomboweb () function is added to the Right to automatically generate code.
Add the code to be implemented in the function.
Void cbrowserdlg: oncbnselchangecomboweb () <br/>{< br/> // todo: add the control notification handler code here <br/> cstring strinfo; <br/> m_cbwebs.getlbtext (m_cbwebs.getcursel (), strinfo); // obtain the content of the selected option <br/> afxmessagebox (strinfo ); // The modified content is displayed in the pop-up box. <br/>}< br/>