龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VC开发 >

VC++实现工具栏上添加平面组合框控件(4)

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
// If mouse leaves, show flat. if (!rcItem.PtInRect(pt)) { KillTimer (1); if (bPainted == true) { DrawCombo(FC_DRAWNORMAL, ::GetSysColor(COLOR_BTNFACE),::GetSysColor(COLOR_BTNFACE)); bPainted = false;
 // If mouse leaves, show flat.
 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;

精彩图集

赞助商链接