{
CDC dc;
dc.Attach(lpDrawItemStruct->hDC);
VERIFY(lpDrawItemStruct->CtlType==ODT_BUTTON);
CBrush brush;
brush.CreateSolidBrush(RGB(0,0,120));
CRect rect;
rect=lpDrawItemStruct->rcItem;
dc.FillRect(rect,&brush);
/*UINT uStyle = DFCS_BUTTONPUSH;
uStyle|=DFCS_PUSHED;
dc.DrawFrameControl(rect,DFC_BUTTON, uStyle);*/
CString strText;
GetWindowText(strText);
COLORREF cOldColor=dc.SetTextColor(m_TextColor); //m_TextColor
dc.SetBkMode(TRANSPARENT);
dc.DrawText(strText,strText.GetLength(),rect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
// dc.SetTextColor(cOldColor);
CBrush brush1;
brush1.CreateSolidBrush(m_FrameColor); //m_FrameColor
dc.FrameRect(rect,&brush1);
if((lpDrawItemStruct->itemState&ODS_SELECTED)&&(lpDrawItemStruct->itemAction&(ODA_SELECT|ODA_DRAWENTIRE)))
{
COLORREF fc=RGB(0,0,255);
CBrush brush2(fc);
dc.FrameRect(rect,&brush2);
CBrush brush3(RGB(50,100,0));
dc.FillRect(rect,&brush3);
CFont font;
font.CreatePointFont(120,L"宋体");
CFont *pOldFont=dc.SelectObject(&font);
dc.DrawText(strText,strText.GetLength(),rect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
dc.SelectObject(pOldFont);
DeleteObject(font);
}
DeleteObject(brush1);
// DeleteObject(brush1);
DeleteObject(brush);
dc.Detach();
// TODO: 添加您的代码以绘制指定项
}
void CMyButton::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if(false==m_bIsMouseMove)
{
m_TextColor=RGB(0,200,10);
m_FrameColor=RGB(100,100,30);
m_bIsMouseMove=true;
//this->UpdateData(1);
this->Invalidate();
TRACKMOUSEEVENT trackmouseevent;
trackmouseevent.cbSize = sizeof(trackmouseevent);
trackmouseevent.dwFlags = TME_LEAVE;
trackmouseevent.hwndTrack = GetSafeHwnd();
trackmouseevent.dwHoverTime = HOVER_DEFAULT;
_TrackMouseEvent(&trackmouseevent);
}
CButton::OnMouseMove(nFlags, point);
}
void CMyButton::OnMouseLeave()
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
m_TextColor=RGB(255,0,0);
m_FrameColor=RGB(255,0,0);
m_bIsMouseMove=false;
this->Invalidate();
CButton::OnMouseLeave();
}