15,979
社区成员
发帖
与我相关
我的任务
分享
OnPaint()
{
CPaintDC dc(this);
CDC dcCompatibale;
dcCompatibale.CreateCompatibleDC(&dc);
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BAK);
dcCompatibale.SelectObject(&bitmap);
CRect rect;
GetClientRect(&rect);
BITMAP bMap;
bitmap.GetBitmap(&bMap);
dc.SetStretchBltMode(COLORONCOLOR);//防止图片失真
dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcCompatibale,0,0,bMap.bmWidth,bMap.bmHeight,SRCCOPY);
}
BOOL CDLG1Dlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CDC dcCompatibale;
dcCompatibale.CreateCompatibleDC(pDC);
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BITMAP1);
CBitmap *pOldBitmap = dcCompatibale.SelectObject(&bitmap);
CRect rect;
GetClientRect(&rect);
BITMAP bMap;
bitmap.GetBitmap(&bMap);
pDC->SetStretchBltMode(COLORONCOLOR);//防止图片失真
pDC->StretchBlt(0,0,rect.Width(),rect.Height(),
&dcCompatibale,
0,0,bMap.bmWidth,bMap.bmHeight,SRCCOPY);
dcCompatibale.SelectObject(pOldBitmap);
dcCompatibale.DeleteDC();
bitmap.DeleteObject();
return TRUE;
//return CDialog::OnEraseBkgnd(pDC);
}
void CDLG1Dlg::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos)
{
CDialog::OnWindowPosChanged(lpwndpos);
// TODO: Add your message handler code here
InvalidateRect(NULL);
}