BOOL CBaseBmpWnd :: OnEraseBkgnd (CDC *pDC)标签:文字,rcClient,代码,nx,ny,picDC,一段,szCaption,pDC From: https://blog.51cto.com/u_15942605/6024292
{
// If no bitmap is loaded, behave like a normal dialog box
if (!m_bBitmapExists)
return CWnd :: OnEraseBkgnd (pDC); if(NULL==m_bmBitmap)
return CWnd :: OnEraseBkgnd (pDC); CDC picDC;
picDC.CreateCompatibleDC (pDC);
CBitmap *pOldBmp;
pOldBmp = picDC.SelectObject (m_bmBitmap);
//picDC.SelectObject(pOldBmp); BITMAP bm;
m_bmBitmap->GetBitmap(&bm); CRect rcClient;
GetClientRect(&rcClient); int width = min (bm.bmWidth, rcClient.Width());
int height = min (bm.bmHeight, rcClient.Height());
pDC->BitBlt (0,0,width,height,&picDC,0,0,SRCCOPY); //if(m_strCaption!=_T(""))//输出字体
//{
int nOldMode=pDC->SetBkMode(TRANSPARENT);
if(m_uWndStatus == 1)
{
m_clrText=GetSysColor(COLOR_HIGHLIGHT);
}
else if (m_uWndStatus==0)
{
m_clrText=RGB(148,148,148);
} COLORREF clrOldText = pDC->SetTextColor(m_clrText);
CFont* pOldFont = pDC->SelectObject(&m_ft);
CSize szCaption = pDC->GetTextExtent(m_strCaption); int nx ,ny;
nx = (rcClient.Width() - szCaption.cx ) /2;
ny =(rcClient.Height() - szCaption.cy - m_uBottomEage) /2; //picDC.BitBlt(nx,ny,szCaption.cx,szCaption.cy,pDC,nx,ny,SRCCOPY);
pDC->TextOutW(nx,ny,m_strCaption); //}
pDC->SelectObject(pOldBmp);
pDC->SetTextColor(clrOldText);
pDC->SelectObject(pOldFont);
pDC->SetBkMode(nOldMode); picDC.DeleteDC();
return TRUE;
}