mfc显示位图,缩小后再显示就乱套了 20
代码如下:CPaintDCdc(this);//用于绘制的设备上下文CDCmemDC;CRectrcClient;GetClientRect(&rcClient);mem...
代码如下:
CPaintDC dc(this); // 用于绘制的设备上下文
CDC memDC;
CRect rcClient;
GetClientRect(&rcClient);
memDC.CreateCompatibleDC(&dc);
HDC hDC;
hDC = memDC.GetSafeHdc();
CBitmap memBitmap;
//memBitmap.CreateCompatibleBitmap(&dc, rcClient.Width(), rcClient.Height());
memBitmap.Attach(m_hBkground);
BITMAP bm = {0};
int nErr;
int nRet;
nRet = memBitmap.GetBitmap(&bm);
if (nRet == 0)
{
nErr = GetLastError();
return CDialog::OnPaint();
}
CBitmap *pOldBitmap = memDC.SelectObject(&memBitmap);
dc.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &memDC, 0, 0, SRCCOPY);
memDC.SelectObject(pOldBitmap);
memBitmap.DeleteObject();
memDC.DeleteDC(); 展开
CPaintDC dc(this); // 用于绘制的设备上下文
CDC memDC;
CRect rcClient;
GetClientRect(&rcClient);
memDC.CreateCompatibleDC(&dc);
HDC hDC;
hDC = memDC.GetSafeHdc();
CBitmap memBitmap;
//memBitmap.CreateCompatibleBitmap(&dc, rcClient.Width(), rcClient.Height());
memBitmap.Attach(m_hBkground);
BITMAP bm = {0};
int nErr;
int nRet;
nRet = memBitmap.GetBitmap(&bm);
if (nRet == 0)
{
nErr = GetLastError();
return CDialog::OnPaint();
}
CBitmap *pOldBitmap = memDC.SelectObject(&memBitmap);
dc.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &memDC, 0, 0, SRCCOPY);
memDC.SelectObject(pOldBitmap);
memBitmap.DeleteObject();
memDC.DeleteDC(); 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询