void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item
UINT uStyle = DFCS_BUTTONPUSH;
// This code only works with buttons.
ASSERT(lpDrawItemStruct->CtlType == ODT_BUTTON);
// If drawing selected, add the pushed style to DrawFrameControl.
if (lpDrawItemStruct->itemState & ODS_SELECTED)
uStyle |= DFCS_PUSHED;
// Draw the button frame.
::DrawFrameControl(lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem, DFC_BUTTON, uStyle); //这句要注释掉
// Get the button's text.
CString strText;
GetWindowText(strText);
CBrush brushT(RGB(0,0,0)); //背景色
CBrush brushF(RGB(255, 255, 255)); //边框颜色
CDC dc;
COLORREF crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(255,255,255)); //设置字体颜色
dc.Attach(lpDrawItemStruct->hDC);
dc.FillRect(&lpDrawItemStruct->rcItem, &brushT); //填充按钮背景色
::SetBkColor(lpDrawItemStruct->hDC, RGB(0, 0, 0)); //设置字体背景色
::DrawText(lpDrawItemStruct->hDC, strText, strText.GetLength(), &lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER); //重绘文字
dc.FrameRect(&lpDrawItemStruct->rcItem, &brushF); //绘按钮边框
::SetBkMode(lpDrawItemStruct->hDC, TRANSPARENT); //设置透明模式
::SetTextColor(lpDrawItemStruct->hDC, crOldColor); //选回字体原来的颜色
dc.Detach();
}