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

  • A help desk is critical to the operations of an IT services business. As a centralized intake location for technical issues, it allows for a responsive and timely solution to get clients and their staff back to business as usual. In addition to handling immediate IT issues, a help desk performs several proactive tasks to ensure clients' IT systems remain operational and downtime is minimized. Thus, utilizing a help desk and following best practices can improve the productivity, efficiency and satisfaction of …

  • You probably have several goals for your patient portal of choice. Is "community" one of them? With a bevy of vendors offering portal solutions, it can be challenging for a hospital to know where to start. Fortunately, YourCareCommunity helps ease the decision-making process. Read this white paper to learn more. "3 Ways Clinicians can Leverage a Patient Portal to Craft a Healthcare Community" is a published document owned by www.medhost.com

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds