响应WM_ERASEBKGND消息,在消息响应函数中加入贴背景图的代码,这样的话就不会出现背景遮盖按钮的情况
如下
BOOL CPlayerDlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CRect rcClient;
GetClientRect(&rcClient);
BITMAP bm;
m_BkGndBmp.GetBitmap(&bm);
CDC memDC;
memDC.CreateCompatibleDC(pDC);
CBitmap *pOldBmp = memDC.SelectObject(&m_BkGndBmp);
pDC->StretchBlt(0,0,rcClient.Width(),rcClient.Height(),&memDC,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
memDC.SelectObject(pOldBmp);
memDC.DeleteDC();
return TRUE;
// return CDialog::OnEraseBkgnd(pDC);
}
其中m_BkGndBmp.LoadBitmap(IDB_BITMAP2);