C++实现仿Office风格的颜色选取框代码(4)
SelectObject(hdc, hbold);
DeleteObject(hb);
DeleteObject(hpen);
}
else if (row==5)
{
//绘自定义文字
GetClientRect(m_hwnd, &rc);
if (correction) OffsetRect(&rc, -correction, -correction); //校正位置
InflateRect(&rc, -5, -5);
rc.top = 5*18+10;
if (hot)
{
hb = CreateSolidBrush(GetSysColor(m_bMouseDown ? COLOR_HIGHLIGHT : COLOR_INACTIVECAPTIONTEXT));
hpen = CreatePen(PS_SOLID, 1, GetSysColor(m_bMouseDown ? COLOR_WINDOWFRAME : COLOR_INACTIVECAPTION));
hbold = SelectObject(hdc, hb);
holdpen = SelectObject(hdc, hpen);
Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
SelectObject(hdc, holdpen);
SelectObject(hdc, hbold);
DeleteObject(hb);
DeleteObject(hpen);
}
else
FillRect(hdc, &rc, NULL);
//if (b_CustomColor) rc.right = 7*18;
SetBkMode(hdc, TRANSPARENT);
HFONT m_Font = CreateFont(-12, 0, 0, 0, 400, 0, 0, 0, GB2312_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "宋体");
HGDIOBJ m_OldFont = SelectObject(hdc, m_Font);
DrawText(hdc, "其他颜色...", -1, &rc, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
SelectObject(hdc, m_OldFont);
DeleteObject(m_Font);
if (m_bCustomColor)
{
rc.right = 8*18+3;
rc.left = 7*18;
rc.top += 2;
rc.bottom = rc.top + 15;
hb = CreateSolidBrush(m_Color);
hbold = SelectObject(hdc, hb);
Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
//SelectObject(hdc, holdpen);
DeleteObject(hb);
}
}
}
//重绘指定区域
void CColorPicker::ReDraw(byte row, byte col, bool hot)
{
HDC hdc = GetWindowDC(m_hwnd);
Draw(hdc, row, col, hot, 0);
ReleaseDC(m_hwnd, hdc);
}





