void CColorButtonCtrl::DrawCaption(CDC* pDC, CRect& rc, COLORREF lColor) { int cx = 0; int cy = 0; CSize size; // set font CFont* pOldFont; pOldFont = SelectFontObject(pDC, InternalGetFont()); // get the bounds of the caption text ::GetTextExtentPoint32( pDC->m_hDC, // handle of device context m_sCaption, // address of text string m_sCaption.GetLength(), // number of characters in string &size); // address of size structure cx = (rc.left + rc.right) / 2 - size.cx / 2; cy = (rc.top + rc.bottom) / 2 - size.cy / 2; // offset clipping region CRgn rgn; rgn.CreateRectRgn(rc.left + m_BevelWidth + 1, rc.top + m_BevelWidth + 1, rc.right - m_BevelWidth - 1, rc.bottom - m_BevelWidth - 1); pDC->SelectClipRgn(&rgn); // make text background transparent pDC->SetBkMode(TRANSPARENT); // etch the caption if disabled if (!GetEnabled() ) { pDC->SetTextColor(::GetSysColor(COLOR_3DHILIGHT)); pDC->TextOut(cx+1, cy+1, m_sCaption); } // set text color pDC->SetTextColor(lColor); // set panel caption pDC->TextOut(cx, cy, m_sCaption); // release font pDC->SelectObject(pOldFont); // delete region DeleteObject(&rgn); }
pOldHeadingFont = SelectFontObject(pdc, m_fontHeading);