当窗口大小变化时,怎么让布画外的图重绘? 还要让程序尽量简洁。
voidCdisplayViaGDIView::createDC(CDC*pdc){bitmap.CreateCompatibleBitmap(pdc,1000,3000...
void CdisplayViaGDIView::createDC(CDC* pdc)
{
bitmap.CreateCompatibleBitmap(pdc, 1000, 3000);
MemDC.CreateCompatibleDC(pdc);
pOldBmp = MemDC.SelectObject(&bitmap);
MemDC.FillSolidRect(0,0,1000,3000,RGB(255,255,255));
pdc->BitBlt(0,0,1000,3000, &MemDC,0,0,SRCCOPY);
}
void CdisplayViaGDIView::OnDraw(CDC* /*pDC*/)
{
/*CRect rect;
GetClientRect(&rect);
GetDC()->FillSolidRect(&rect,RGB(255,255,255));*/
GetDC()->StretchBlt(rect.left,rect.top,rect.left+1000,rect.top+3000,&MemDC,0,0,1000,3000,SRCCOPY); //重绘超出范围的很难看。
// TODO: add draw code for native data here
}
是应该用pDC. 另外我把 "风魂永恒" 的代码放在消息响应函数中了。
void CdisplayViaGDIView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
GetClientRect(&rect);
InvalidateRect(&rect, TRUE);
}
还是不行。 展开
{
bitmap.CreateCompatibleBitmap(pdc, 1000, 3000);
MemDC.CreateCompatibleDC(pdc);
pOldBmp = MemDC.SelectObject(&bitmap);
MemDC.FillSolidRect(0,0,1000,3000,RGB(255,255,255));
pdc->BitBlt(0,0,1000,3000, &MemDC,0,0,SRCCOPY);
}
void CdisplayViaGDIView::OnDraw(CDC* /*pDC*/)
{
/*CRect rect;
GetClientRect(&rect);
GetDC()->FillSolidRect(&rect,RGB(255,255,255));*/
GetDC()->StretchBlt(rect.left,rect.top,rect.left+1000,rect.top+3000,&MemDC,0,0,1000,3000,SRCCOPY); //重绘超出范围的很难看。
// TODO: add draw code for native data here
}
是应该用pDC. 另外我把 "风魂永恒" 的代码放在消息响应函数中了。
void CdisplayViaGDIView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
GetClientRect(&rect);
InvalidateRect(&rect, TRUE);
}
还是不行。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询