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
  • 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
  • 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
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Download the Information Governance Survey Benchmark Report to gain insights that can help you further establish business value in your Records and Information Management (RIM) program and across your entire organization. Discover how your peers in the industry are dealing with this evolving information lifecycle management environment and uncover key insights such as: 87% of organizations surveyed have a RIM program in place 8% measure compliance 64% cannot get employees to "let go" of information for …

  • With JRebel, developers get to see their code changes immediately, fine-tune their code with incremental changes, debug, explore and deploy their code with ease (both locally and remotely), and ultimately spend more time coding instead of waiting for the dreaded application redeploy to finish. Every time a developer tests a code change it takes minutes to build and deploy the application. JRebel keeps the app server running at all times, so testing is instantaneous and interactive.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds