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

  • Today's agile organizations pose operations teams with a tremendous challenge: to deploy new releases to production immediately after development and testing is completed. To ensure that applications are deployed successfully, an automatic and transparent process is required. We refer to this process as Zero Touch Deployment™. This white paper reviews two approaches to Zero Touch Deployment--a script-based solution and a release automation platform. The article discusses how each can solve the key …

  • On-demand Event Event Date: December 18, 2014 The Internet of Things (IoT) incorporates physical devices into business processes using predictive analytics. While it relies heavily on existing Internet technologies, it differs by including physical devices, specialized protocols, physical analytics, and a unique partner network. To capture the real business value of IoT, the industry must move beyond customized projects to general patterns and platforms. Check out this webcast and join industry experts as …

Most Popular Programming Stories

More for Developers

RSS Feeds