Controls Articles and Tutorials

Office Style Flat Combo Box

Author: Kirk Stowell
Platform: Visual C++ MFC
Downloads: - Source Files with Demo Project [ 33.38 Kb ] - Source Files Only [ 4.68 Kb ]

The CXTFlatComboBox class can easily give your application the Flat Look to your standard CComboBox control as seen in many of the Microsoft® Office products. To use the control, simply add the files XTFlatComboBox.cpp and XTFlatComboBox.h to your project, you can use the Class Wizard to add the CComboBox member variable ( Class Wizard -> Member Variables Tab -> Add Variable ) and rename CComboBox to CXTFlatComboBox.

Office Style Combo Box

Below is an example of how you might add the control to your project. The CXTFlatComboBox class is a member of the Standard Toolkit. Feel free to use it in any of your projects.

Header file:

// Dialog Data
    CXTFlatComboBox    m_DDCombo;
    CXTFlatComboBox    m_DLCombo;
    BOOL    m_bDDAutoComp;
    BOOL    m_bDDDisable;
    BOOL    m_bDLDisable;

Implementation file:

void CFlatComboDemoDlg::DoDataExchange(CDataExchange* pDX)
    DDX_Control(pDX, IDC_DROPDOWN_COMBO, m_DDCombo);
    DDX_Control(pDX, IDC_DROPLIST_COMBO, m_DLCombo);
    DDX_Check(pDX, IDC_DROPDOWN_DISABLE, m_bDDDisable);
    DDX_Check(pDX, IDC_DROPLIST_DISABLE, m_bDLDisable);