Create a combo box in the toolbar

Source: Internet
Author: User

1. Define a combo box ID in resource. h.

#define ID_MY_COMBOBOX                  1032

2. In the. RC resource file, add a button with the ID as defined above for the toolbar.

IDR_MAINFRAME TOOLBAR  16, 15BEGIN    ......    BUTTON      ID_MY_COMBOBOX    ......END

3. Define a combo box object in mainfrm. h.

Protected: // control bar embedded member cstatusbar m_wndstatusbar; ctoolbar m_wndtoolbar; ccombobox m_wndcombobox; // A combox object

4. Define a function declaration for creating a combo box in mainfrm. h.

public:BOOL CreateComboBox();

5. Implement the previously declared function in mainfrm. cpp.

Bool cmainframe: createcombobox () {int nwidth = 200; // The width of the combox int nheight = 200; // The height of the combox 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. Call the create combo box function in the oncreate () function of cmainframe.

Int cmainframe: oncreate (maid) {... 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.