VC++实现工具栏上添加平面组合框控件(4)
if (!rcItem.PtInRect(pt)) {
KillTimer (1);
if (bPainted == true) {
DrawCombo(FC_DRAWNORMAL, ::GetSysColor(COLOR_BTNFACE),::GetSysColor(COLOR_BTNFACE));
bPainted = false;
}
return;
}
// On mouse over, show raised.
else {
if (bPainted == true)
return;
else {
bPainted = true;
DrawCombo(FC_DRAWRAISED, ::GetSysColor(COLOR_BTNSHADOW),::GetSysColor(COLOR_BTNHIGHLIGHT));
}
}
CComboBox::OnTimer(nIDEvent);
}
void CFlatComboBox::OnPaint()
{
Default();
DrawCombo(FC_DRAWNORMAL, ::GetSysColor(COLOR_BTNFACE),::GetSysColor(COLOR_BTNFACE));
}
void CFlatComboBox::DrawCombo(DWORD dwStyle, COLORREF clrTopLeft, COLORREF clrBottomRight)
{
CRect rcItem;
GetClientRect(&rcItem);
CDC* pDC = GetDC();
// Cover up dark 3D shadow.
pDC->Draw3dRect(rcItem, clrTopLeft, clrBottomRight);
rcItem.DeflateRect(1,1);
if (!IsWindowEnabled()) {
pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNHIGHLIGHT),::GetSysColor(COLOR_BTNHIGHLIGHT));
}
else {
pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNFACE),::GetSysColor(COLOR_BTNFACE));
}
// Cover up dark 3D shadow on drop arrow.
rcItem.DeflateRect(1,1);
rcItem.left = rcItem.right-Offset();
pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNFACE),::GetSysColor(COLOR_BTNFACE));
// Cover up normal 3D shadow on drop arrow.
rcItem.DeflateRect(1,1);
pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNFACE),::GetSysColor(COLOR_BTNFACE));
if (!IsWindowEnabled()) {
return;
}
switch (dwStyle)
{
case FC_DRAWNORMAL:
rcItem.top -= 1;
rcItem.bottom += 1;
pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNHIGHLIGHT),::GetSysColor(COLOR_BTNHIGHLIGHT));
rcItem.left -= 1;
pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNHIGHLIGHT),::GetSysColor(COLOR_BTNHIGHLIGHT));
break;
case FC_DRAWRAISED:
rcItem.top -= 1;
rcItem.bottom += 1;
pDC->Draw3dRect(rcItem, ::GetSysColor(COLOR_BTNHIGHLIGHT),::GetSysColor(COLOR_BTNSHADOW));
break;