LRESULT CTestDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
if(message==WM_ERASEBKGND)
{
CRect rc;
GetClientRect(&rc);
CDC * pDC = GetDC();
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP1);
CDC dc;
dc.CreateCompatibleDC(pDC);
dc.SelectObject(&bmp);
pDC->BitBlt(0,0,rc.Width(),rc.Height(),&dc,0,0,SRCCOPY);
ReleaseDC(pDC);
return 1;
}
return CDialog::WindowProc(message, wParam, lParam);
}
不行吗?
{
// TODO: Add your specialized code here and/or call the base class
if(message==WM_ERASEBKGND)
{
CRect rc;
GetClientRect(&rc);
CDC * pDC = GetDC();
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP1);
CDC dc;
dc.CreateCompatibleDC(pDC);
dc.SelectObject(&bmp);
pDC->BitBlt(0,0,rc.Width(),rc.Height(),&dc,0,0,SRCCOPY);
ReleaseDC(pDC);
return 1;
}
return CDialog::WindowProc(message, wParam, lParam);
}
不行吗?
void CMyDialog::OnPaint()
{
CPaintDC dc(this)
CDC memdc;
memdc.CreateCompatibleDC(&dc);
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP1);
BITMAP bitmap;
bmp.GetBitmap(&bitmap);
memdc.SelectObject(&bmp);
CRect r;
GetClientRect(&r);
dc.BOOL StretchBlt(0,0,r.Width(),r.Height(), &memdc, 0,0,bitmap.bmWidth ,bitmap.bmHeight , SRCCOPY);
CDialog::OnPaint();
}