Articles and Tutorials

Office Style Flat Combo Box

Author: Kirk Stowell
Platform: Visual C++ MFC
Downloads:
FlatComboBox_prj.zip - Source Files with Demo Project [ 33.38 Kb ]
FlatComboBox_src.zip - 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
    //{{AFX_DATA(CFlatComboDemoDlg)
    enum { IDD = IDD_FLATCOMBODEMO_DIALOG };
    CXTFlatComboBox    m_DDCombo;
    CXTFlatComboBox    m_DLCombo;
    BOOL    m_bDDAutoComp;
    BOOL    m_bDDDisable;
    BOOL    m_bDLDisable;
//}}AFX_DATA

Implementation file:

void CFlatComboDemoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CFlatComboDemoDlg)
    DDX_Control(pDX, IDC_DROPDOWN_COMBO, m_DDCombo);
    DDX_Control(pDX, IDC_DROPLIST_COMBO, m_DLCombo);
    DDX_Check(pDX, IDC_DROPDOWN_AUTOCOMP, m_bDDAutoComp);
    DDX_Check(pDX, IDC_DROPDOWN_DISABLE, m_bDDDisable);
    DDX_Check(pDX, IDC_DROPLIST_DISABLE, m_bDLDisable);
    //}}AFX_DATA_MAP
}

Articles and Tutorials