void CColorPaletteButton::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	
	// Do not call CButton::OnPaint() for painting messages
   COLORREF buttonColor = (m_appPalette.isPaletteDevice() ? 
      PALETTEINDEX(m_appPalette.getEditIndex()) : 
      m_appPalette.getEditColor() );

   TRACE("CColorPaletteButton::OnPaint() - buttonColor = %08x\n",buttonColor);

   CRect rect;
   GetClientRect(&rect);
   CPen penHighlight(PS_SOLID,1,GetSysColor(COLOR_BTNHIGHLIGHT));
   CPen* oldPen = dc.SelectObject(&penHighlight);
   dc.MoveTo(rect.left,rect.bottom);
   dc.LineTo(rect.right,rect.bottom);
   dc.LineTo(rect.right,rect.top - 1);

   CPen penShadow(PS_SOLID,1,GetSysColor(COLOR_BTNSHADOW));
   dc.SelectObject(&penShadow);
   dc.MoveTo(rect.left,rect.bottom - 1);
   dc.LineTo(rect.left,rect.top);
   dc.LineTo(rect.right,rect.top);

   CPen penFace(PS_SOLID,1,GetSysColor(COLOR_BTNFACE));
   dc.SelectObject(&penFace);
   dc.MoveTo(rect.left + 1,rect.bottom - 1);
   dc.LineTo(rect.right - 1,rect.bottom - 1);
   dc.LineTo(rect.right - 1,rect.top);

   CPen penDarkShadow(PS_SOLID,1,GetSysColor(COLOR_3DDKSHADOW));
   dc.SelectObject(&penDarkShadow);
   dc.MoveTo(rect.left + 1,rect.bottom - 2);
   dc.LineTo(rect.left + 1,rect.top + 1);
   dc.LineTo(rect.right - 1,rect.top + 1);

   dc.SelectObject(oldPen);

   m_appPalette.pushPalette(&dc);

   CBrush brush;
   brush.CreateSolidBrush(buttonColor);
   CBrush* oldBrush = dc.SelectObject(&brush);
   rect.top += 2;
   rect.left += 2;
   rect.bottom -= 1;
   rect.right -= 1;
   dc.SelectObject(&brush);
   dc.FillRect(&rect,&brush);

   dc.SelectObject(oldBrush);

   m_appPalette.popPalette(&dc);
}
void COptionTreeItemLineThikComboBox::DrawAttribute(CDC *pDC, const RECT &rcRect)
{
	// If we don't have focus, text is drawn.
	if (m_bFocus == TRUE)
	{
		return;
	}

	// Make sure options aren't NULL
	if (m_otOption == NULL)
	{
		return;
	}

	// Make sure there is a window
	if (!IsWindow(GetSafeHwnd()))
	{
		return;
	}

	// Set window position
	if (IsWindow(GetSafeHwnd()))
	{
		MoveWindow(m_rcAttribute.left, m_rcAttribute.top, m_rcAttribute.Width(), m_rcAttribute.Height());
	}

	COLORREF	crNormal = GetSysColor( COLOR_WINDOW );

	CRect rrr = rcRect;
	pDC->SetBkColor( crNormal );					// Set BG To Highlight Color
	pDC->FillSolidRect( &rrr, crNormal );	// Erase Item

	CPen penHighlight(PS_SOLID, m_line_thickness+1, RGB(0,0,0));
	CPen* pOldPen = pDC->SelectObject(&penHighlight);

	pDC->MoveTo(rcRect.left,
		rcRect.top+(rcRect.bottom-rcRect.top)/2);
	pDC->LineTo(rcRect.right,
		rcRect.top+(rcRect.bottom-rcRect.top)/2);

	pDC->SelectObject(pOldPen);
}
void CBeautifulCanlendarYearCombox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	
	if (!IsWindowEnabled())
	{
        CBrush brDisabled(RGB(192,192,192)); // light gray
		CBrush* pOldBrush = pDC->SelectObject(&brDisabled);
		CPen penDisabled(PS_SOLID, 1, RGB(192,192,192));
        CPen* pOldPen = pDC->SelectObject(&penDisabled);

		
        //以下是绘制文本的部分
		CRect textRect = lpDrawItemStruct->rcItem;
        textRect.left = textRect.left + 6;  
		

		CString strText;
	    if(lpDrawItemStruct->itemID != LB_ERR)
		{
		   GetLBText( lpDrawItemStruct->itemID,strText);
        }

		pDC->SetTextColor(RGB(160,160,160));
    
		CFont newFont,*oldFont;
		newFont.CreatePointFont(90,"宋体");
		oldFont = (CFont *)pDC->SelectObject(&newFont);
		pDC->DrawText(strText,&textRect,DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_END_ELLIPSIS);
		pDC->SelectObject(oldFont); 
		pDC->SelectObject(pOldBrush);
		pDC->SelectObject(pOldPen);
		return;
	}


	CString strText;
	if(lpDrawItemStruct->itemID != LB_ERR)
	{
		   GetLBText( lpDrawItemStruct->itemID,strText);
    }


	if(strText == "-" || strText == "+")//如果文本是- 则表示要创建减少年数的按钮
	{
		 
		CBrush brHighlight(RGB(231,241,245)); 
		CBrush* pOldBrush = pDC->SelectObject(&brHighlight);
		CPen penHighlight(PS_SOLID, 1, RGB(107,141,162));
		CPen* pOldPen = pDC->SelectObject(&penHighlight);
		 
		CRect rcBackground;
        rcBackground.left = lpDrawItemStruct->rcItem.left + 2;
		rcBackground.right = lpDrawItemStruct->rcItem.right - 2;
		rcBackground.top = lpDrawItemStruct->rcItem.top + 2;
        rcBackground.bottom = lpDrawItemStruct->rcItem.bottom - 2;

	 	pDC->Rectangle(&rcBackground);
		pDC->SetBkMode(TRANSPARENT);
       	pDC->SetTextColor(RGB(255,0,0));
		
		//以下是绘制文本的部分


		pDC->SelectObject(pOldBrush);
		pDC->SelectObject(pOldPen);
		return;
    }


	// Selected
	if ((lpDrawItemStruct->itemState & ODS_SELECTED) 
		&& (lpDrawItemStruct->itemAction & (ODA_SELECT | ODA_DRAWENTIRE))) 
	{
		CBrush brHighlight(RGB(231,241,245)); 
		CBrush* pOldBrush = pDC->SelectObject(&brHighlight);
		CPen penHighlight(PS_SOLID, 1, RGB(107,141,162));
		CPen* pOldPen = pDC->SelectObject(&penHighlight);
		 
	 	pDC->Rectangle(&lpDrawItemStruct->rcItem);
		pDC->SetBkMode(TRANSPARENT);
       	pDC->SetTextColor(RGB(255,0,0));
		
		//以下是绘制文本的部分
		CRect textRect = lpDrawItemStruct->rcItem;
        textRect.left = textRect.left + 6;  
		
		CString strText;
	    if(lpDrawItemStruct->itemID != LB_ERR)
		{
		   GetLBText( lpDrawItemStruct->itemID,strText);
        }
    
		CFont newFont,*oldFont;
		newFont.CreatePointFont(90,"宋体");
		oldFont = (CFont *)pDC->SelectObject(&newFont);
		pDC->DrawText(strText,&textRect,DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_END_ELLIPSIS);
        pDC->SelectObject(oldFont);
		pDC->SelectObject(pOldBrush);
		pDC->SelectObject(pOldPen);
	}

	// De-Selected
	if (!(lpDrawItemStruct->itemState & ODS_SELECTED) 
		&& (lpDrawItemStruct->itemAction & (ODA_SELECT | ODA_DRAWENTIRE))) 
	{
		CBrush brWindow(::GetSysColor(COLOR_WINDOW)); 
		CBrush* pOldBrush = pDC->SelectObject(&brWindow);
		CPen penHighlight(PS_SOLID, 1, ::GetSysColor(COLOR_WINDOW));
		CPen* pOldPen = pDC->SelectObject(&penHighlight);
		pDC->Rectangle(&lpDrawItemStruct->rcItem);
		pDC->SetBkColor(::GetSysColor(COLOR_WINDOW));
       	pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));

		//以下是绘制文本的部分
		CRect textRect = lpDrawItemStruct->rcItem;
        textRect.left = textRect.left + 6;  
		
		CString strText;
	    if(lpDrawItemStruct->itemID != LB_ERR)
		{
		   GetLBText( lpDrawItemStruct->itemID,strText);
        }

		CFont newFont,*oldFont;
		newFont.CreatePointFont(90,"宋体");
		oldFont = (CFont *)pDC->SelectObject(&newFont);
		pDC->DrawText(strText,&textRect,DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_END_ELLIPSIS);
        pDC->SelectObject(oldFont);

		pDC->SelectObject(pOldBrush);
		pDC->SelectObject(pOldPen);
	}
	
}