Office Style Flat ComboBox


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

For the latest updates and source code click here.

Office Style Flat ComboBox Demo

Environment: VC5, VC6, WIN9x, NT4

This control easily gives your application the Flat Look that is seen in the Microsoft office products. To use the control, simply add the files CCJFlatComboBox.cpp and CCJFlatComboBox.h to your project. You can use Class Wizard to add the CCJFlatComboBox member variables ( you most likely will have to rebuild the .clw file associated with your project ), or just replace any instance of CComboBox, with CCJFlatComboBox. Below is and example of how you might approach this.

Header file:

CCJFlatComboBox m_DDCombo;

Implementation file:



  • Chris Maunder - For letting me use his color picker class. I made some modifications to the appearance of the control that is used in this demo. My modifications are noted.
  • Gilberto Botaro - For his help with adding auto completion to the CCJFlatComboBox class.
  • Vachik Hovhannissian and Danilo Lax - For help with fixing focus and message handling bugs.
  • Yosh Yamashita - For help with fixing accelerator bug.
  • Shannon McCoy - For suggestions on using ::GetSysColor(...) and ::GetSystemMetrics(...) more efficiently.
  • Todd Brannam - For help with fixing offset bug to use GetSystemMetrics().


Download demo project - 46 Kb
Download source - 6 Kb


  • How to use the control in a DialogBar ???

    Posted by Legacy on 11/13/2002 08:00am

    Originally posted by: Weier

    It seems no DDX operation can be done in a dialogbar????

  • *** WARNING *** This stuff is dangerous!

    Posted by Legacy on 12/12/2001 08:00am

    Originally posted by: Matthias Wolff

    I followd Kirks link to the "new" version of the combobox (www.codejock.com) and downloaded some of their demos.


    This software crashes Windows NT 4.0 (SP6) with a KMODE_EXCEPTION_NOT_HANDLED (or in simple words: a blue screen) as soon as you press any butten or open any menu.


    So if you love your NT you'd better keep off this stuff.


  • BUG in CCJFlatComboBox::DrawCombo()

    Posted by Legacy on 12/06/2000 08:00am

    Originally posted by: TheFlashback


    neat code! looks very good. The only thing
    is that in the CCJFlatComboBox::DrawCombo() function
    you have the following:

    if (!IsWindowEnabled()) {

    You should release the DC before returning as you
    do at the very end of this function.



  • Office style Combo : auto-incomplete

    Posted by Legacy on 11/29/1999 08:00am

    Originally posted by: Dennis McLeod

    The autocomplete feature works nicely as long as you don't want to back up beyond the matching part of your typed string. For instance... if you type "Some Mean" ... it autocompletes with the "Some Meaningless".. which is the desired result. However, If you now try to backspace because you wanted to type "Some Meanie".. it will not let you. You have to select and delete the whole string in order to start fresh.
    ~Dennis McLeod


    Posted by Legacy on 09/12/1999 07:00am

    Originally posted by: Kirk Stowell


    Until I am able to update this article, as an alternative, please visit this link http://www.codejock.com/ for the latest updates. My email address has changed also, please respond to kstowell@codejock.com...

    Kirk Stowell

  • Scrollbar

    Posted by Legacy on 08/26/1999 07:00am

    Originally posted by: Paul Reynolds

    Where is the flat scrollbar drawing to go with the rest? Looks weird with it all being flat except the scrollbar...

  • Tab functionality lost

    Posted by Legacy on 06/28/1999 07:00am

    Originally posted by: sheik

    when i press tab, it does not tab to other controls

  • Where is the - 02 Nov 1998 - Added OnSetFocus(), OnKillFocus()... Code?

    Posted by Legacy on 02/03/1999 08:00am

    Originally posted by: Robert Clark


    02 Nov 1998 - Added OnSetFocus(), OnKillFocus() and modified OnPaint() so the control remains beveled until it actually looses focus - (Vachik Hovhannissian).

    code is not in the example listed here.

    I tried to implement it myself and it works fine for DROPDOWNLIST style combo boxes, but not for DROPDOWN style combo's which have a child EDIT control. The latter style does not receive the proper setfocus/killfocus messages, the child edit control gets them to the focus cannot be accurate.

    Has anybody experienced this and found a solution before?

  • MS Thumbsize bug

    Posted by Legacy on 12/31/1998 08:00am

    Originally posted by: Shannon McCoy

    Running NT4 IE4SP1

    When testing your code to see if color changes where handled properly I noticed some painting glitches. If you go to the Control Panel->Display Appearence tab and change the scheme from "Windows Standard" to someting else like "Pumpkin(large)" the thumb doesn't paint right. Upon further testing I noticed that the thumbs in the combo box on the Display property sheet didn't resize either. The bug seems to be in MS's code. So instead of using GetSystemMeterics() on every paint you have to call it once during initialization and store the value. ( like in a member variable). Also instead of calling GetSystemColor() over and over it would be better to store the colors in member vars and handle the OnSystemColorChange message to reset them if neccesary IMHO.

    m_bLBtnDown = false;
    m_Offset = ::GetSystemMetrics( SM_CXHTHUMB );
    m_ButtonHiliteColor = ::GetSysColor( COLOR_BTNHIGHLIGHT );
    m_ButtonShadowColor = ::GetSysColor( COLOR_BTNSHADOW );
    m_ButtonFaceColor = ::GetSysColor( COLOR_BTNFACE );

    void CFlatComboBox::DrawCombo(DWORD dwStyle, COLORREF clrTopLeft, COLORREF clrBottomRight)
    //Blah Blah Blah

    // Cover up dark 3D shadow on drop arrow.
    rcItem.left = rcItem.right- m_Offset;
    pDC->Draw3dRect(rcItem, m_ButtonFaceColor,

    //Blah Blah Blah

    void CFlatComboBox::OnSysColorChange()

    m_ButtonHiliteColor = ::GetSysColor( COLOR_BTNHIGHLIGHT );
    m_ButtonShadowColor = ::GetSysColor( COLOR_BTNSHADOW );
    m_ButtonFaceColor = ::GetSysColor( COLOR_BTNFACE );


  • Inconsistencies compared to MSWord flat toolbar combos

    Posted by Legacy on 11/09/1998 08:00am

    Originally posted by: Lee Alexander

    The following is a list of inconsistencies the flat combo has compared with MSWord:

    1. The height of the control is not the same as MSWord even when the same font is used "Tahoma".

    2. When changing the default size of a scroll button via control panel the Flat Combo button when created has the same size (as is the case with normal Combos), however MSWord does not change based on this setting. I think it is better to follow the MSWord approach especially on toolbars.

    3. (Related to point 2) Drop button is not the same size as MSWord.

    4. When the control is disabled the drop arrow does bit have the same colour as MSWord flat combo.

    5. When the flat control gets focus it does not stay in 3D mode.

    Cheers Lee

  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date