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

  • IBM Worklight is a mobile application development platform that lets you extend your business to mobile devices. It is designed to provide an open, comprehensive platform to build, run and manage HTML5, hybrid and native mobile apps.

  • On-demand Event Event Date: October 23, 2014 Despite the current "virtualize everything" mentality, there are advantages to utilizing physical hardware for certain tasks. This is especially true for backups. In many cases, it is clearly in an organization's best interest to make use of physical, purpose-built backup appliances rather than relying on virtual backup software (VBA - Virtual Backup Appliances). Join us for this webcast to learn why physical appliances are preferable to virtual backup appliances, …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds