Combobox Color Picker 2

This class, CColorComboEx, is a combobox that instead of displaying strings, displays the standard colors much like the one in Developer Studio. It also has support for the "Automatic" color option. To add a color combobox to your project, first add the ColorComboEx.h and ColorComboEx.cpp files into your project. Next, in the resource editor, add a combobox. Make sure that the combobox has the "Drop List" type, the "Fixed" owner draw type, and the "Has Strings" checkbox checked. Now using ClassWizard, add a member variable for the control based on the CColorComboEx class. Just compile and run, and you will have a color combobox.

Download Source (Demo Project) 29KB



Comments

  • Using the CColorComboEx example...

    Posted by Legacy on 04/10/2000 12:00am

    Originally posted by: Henryk Mueller

    Hey there!

    I needed a combo box to let the user choose a color. Fortunately Codeguru provides an example in combo box section! But then I had a problem...

    As a test I inserted a normal combo box to a dialog ressource and created a control variable (CComboBox m_cTest). Of course it worked.

    Then I replaced CComboBox by CColorComboEx in the header file just for a test. It worked too. Fine!

    In my program I have to create the color box at runtime. First I tried it with a normal combo box. No probs! Then with the CColorComboEx:

    Header -

    CColorComboEx* m_pcTest;

    Source -

    BOOL CMyDialog::OnInitDialog()
    {
    CDialog::OnInitDialog();
    CRect ItemRect(10,10,100,50);

    m_pcTest = new CColorComboEx();
    m_pcTest->Create(WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_SORT | CBS_HASSTRINGS, ItemRect,this,IDC_COMBOTEST);
    return TRUE;
    }

    Result: Assertion error in winctrl1.cpp, line 186

    I got the same result for a normal combo box with the CBS_OWNERDRAWFIXED style!!!

    Why can I use CBS_OWNERDRAWFIXED in the resource editor but not when I have to create the control manually? Is anything wrong with the styles???

    I have no idea!

    Is anybody out there who can help me?

    Thanks in advance

    Henryk


    Reply
  • how to create the shortcut for an URL

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

    Originally posted by: Hunter Huang

    I can create a shortcut for the a file,but can not create a shortcut for an URL

    Reply
  • Combo Box clipping

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

    Originally posted by: James Brown

    One work-around would be to make the
    drop down list a child of the desktop window,
    so that it is not clipped by the containing
    list control. This is how standard windows
    combo boxes work.

    James

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

Top White Papers and Webcasts

  • Hybrid cloud platforms need to think in terms of sweet spots when it comes to application platform interface (API) integration. Cloud Velocity has taken a unique approach to tight integration with the API sweet spot; enough to support the agility of physical and virtual apps, including multi-tier environments and databases, while reducing capital and operating costs. Read this case study to learn how a global-level Fortune 1000 company was able to deploy an entire 6+ TB Oracle eCommerce stack in Amazon Web …

  • Live Event Date: August 19, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT You deployed your app with the Bluemix PaaS and it's gaining some serious traction, so it's time to make some tweaks. Did you design your application in a way that it can scale in the cloud? Were you even thinking about the cloud when you built the app? If not, chances are your app is going to break. Check out this upcoming eSeminar to learn various techniques for designing applications that will scale successfully in Bluemix, for the …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds