#include "common/pch.h" #include "CImgButton.h" CImgButton::CImgButton() { } CImgButton::~CImgButton() { } // BEGIN_MESSAGE_MAP(CImgButton, CBitmapButton) // END_MESSAGE_MAP() void CImgButton::SetTextColor(COLORREF crColor) { TextColor = crColor; } void CImgButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CRect rect = lpDrawItemStruct->rcItem; CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); int nSaveDC = pDC->SaveDC(); UINT state = lpDrawItemStruct->itemState; TCHAR strText[MAX_PATH + 1]; ::GetWindowText(m_hWnd, strText, MAX_PATH); CBitmapButton::DrawItem(lpDrawItemStruct); // pDC->SetTextColor(TextColor); /* if (strText != NULL) { CFont* hFont = GetFont(); CFont* hOldFont = pDC->SelectObject(hFont); CSize szExtent = pDC->GetTextExtent(strText, lstrlen(strText)); CPoint pt(rect.CenterPoint().x - szExtent.cx / 2, rect.CenterPoint().y - szExtent.cy / 2); if (state & ODS_SELECTED) { pt.Offset(1, 1); } int nMode = pDC->SetBkMode(TRANSPARENT); if (state & ODS_DISABLED) { pDC->DrawState(pt, szExtent, strText, DSS_DISABLED, TRUE, 0, (HBRUSH)NULL); } else { pDC->DrawState(pt, szExtent, strText, DSS_NORMAL, TRUE, 0, (HBRUSH)NULL); } pDC->SelectObject(hOldFont); pDC->SetBkMode(nMode); }*/ pDC->RestoreDC(nSaveDC); }