Use the combo box Control

Source: Internet
Author: User

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/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.