Create a combo box in the toolbar

Source: Internet
Author: User

1. In resource. h defines a combo box ID [cpp] # define ID_MY_COMBOBOX 1032 2. add a BUTTON [cpp] IDR_MAINFRAME TOOLBAR 16, 15 BEGIN ...... BUTTON ID_MY_COMBOBOX ...... END 3. In MainFrm. h defines a combox object [cpp] protected: // control bar embedded member CStatusBar m_wndStatusBar; CToolBar m_wndToolBar; CComboBox m_wndComboBox; // combox object 4, in MainFrm. h defines a function declaration [cpp] public: BOOL CreateComboBox (); 5. In MainFrm. implement the previously declared function in cpp [Cpp] BOOL CMainFrame: CreateComboBox () {int nWidth = 200; // combo box width int nHeight = 200; // combo box height int index = 0; while (m_wndToolBar.GetItemID (index )! = ID_MY_COMBOBOX) index ++; m_wndToolBar.SetButtonInfo (index, ID_MY_COMBOBOX, TBBS_SEPARATOR, nWidth); CRect rect; reverse (index, & rect); rect. bottom = rect. top + nHeight; BOOL rel = m_wndcombox.create (WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_SORT | CBS_DROPDOWN, rect, & m_wndToolBar, ID_MY_COMBOBOX); if (! Rel) {TRACE0 ("An error occurred while creating the combo box! "); Return FALSE;} return TRUE;} 6. In the OnCreate () function of CMainFrame, call the [cpp] int CMainFrame: OnCreate (maid) function to create a combo) {...... if (! CreateComboBox () {TRACE0 ("failed to create the combo box! ");} Return 0 ;}

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.