能选择颜色的ComboBox[2]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 mynote 的 blog

    rgb(192, 192, 192),        // light grey
    rgb(128, 128, 128),        // dark grey
    rgb(255, 0, 0),            // red
    rgb(0, 255, 0),            // green
    rgb(255, 255, 0),        // yellow
    rgb(0, 0, 255),            // blue
    rgb(255, 0, 255),        // magenta
    rgb(0, 255, 255),        // cyan
    };

ccombocolorpicker::ccombocolorpicker()
{
    m_binitialized = false;
}

ccombocolorpicker::~ccombocolorpicker()
{
}


begin_message_map(ccombocolorpicker, ccombobox)
    //{{afx_msg_map(ccombocolorpicker)
    on_wm_create()
    //}}afx_msg_map
end_message_map()

/////////////////////////////////////////////////////////////////////////////
// ccombocolorpicker message handlers

int ccombocolorpicker::oncreate(lpcreatestruct lpcreatestruct) 
{
    if (ccombobox::oncreate(lpcreatestruct) == -1)
        return -1;
    
    initializedata();

    return 0;
}

void ccombocolorpicker::presubclasswindow() 
{
    initializedata();
    
    ccombobox::presubclasswindow();
}

void ccombocolorpicker::initializedata()
{
    int nitem;

    if (m_binitialized)
        return;

    for (int ncolor = 0; ncolor hdc))
        return;

    colorref rgbtextcolor = dc.gettextcolor();
    colorref rgbbkcolor = dc.getbkcolor();

    if (lpdrawitemstruct->itemaction & oda_focus)
    {
        dc.drawfocusrect(&lpdrawitemstruct->rcitem);
    }
    else if (lpdrawitemstruct->itemaction & oda_drawentire)
    {
        if (lpdrawitemstruct->itemstate & ods_focus)
            dc.drawfocusrect(&lpdrawitemstruct->rcitem);
        else
            dc.exttextout(0, 0, eto_opaque, &lpdrawitemstruct->rcitem, _t(""), 0, null);
    }

    if (0 <= (int)lpdrawitemstruct->itemid)    // any item selected?
    {
        ::inflaterect(&lpdrawitemstruct->rcitem, -2, -2);
        
        dc.fillsolidrect(&lpdrawitemstruct->rcitem, (colorref)lpdrawitemstruct->itemdata);
        dc.framerect(&lpdrawitemstruct->rcitem, &brushblack);
    }

    // restore the dc state
    dc.settextcolor(rgbtextcolor);

本文关键:能选择颜色的ComboBox
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top