CDC* pDC=GetDC();
CRect rect;
GetClientRect(&rect);
CDC memDC;
memDC.CreateCompatibleDC(NULL);
CBitmap memBitmap;
memBitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
memDC.SelectObject(&memBitmap);
pDC->BitBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY);
memBitmap.DeleteObject();
memDC.DeleteDC();
ReleaseDC(pDC);像上面這段代码,其中的
pDC能保存吗,比如保存为成员变量,供其他成员函数调用m_pDC=GetDC();
同理,
memBitmap 對象能保存嗎?
memDC 对象能保存吗?如果能保存,我每次重繪窗口不用重新创建memBitmap,memDC,直接貼圖就行了
CRect rect;
GetClientRect(&rect);
CDC memDC;
memDC.CreateCompatibleDC(NULL);
CBitmap memBitmap;
memBitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
memDC.SelectObject(&memBitmap);
pDC->BitBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY);
memBitmap.DeleteObject();
memDC.DeleteDC();
ReleaseDC(pDC);像上面這段代码,其中的
pDC能保存吗,比如保存为成员变量,供其他成员函数调用m_pDC=GetDC();
同理,
memBitmap 對象能保存嗎?
memDC 对象能保存吗?如果能保存,我每次重繪窗口不用重新创建memBitmap,memDC,直接貼圖就行了
Identifies the device context for the CWnd client area if successful; otherwise, the return value is NULL. The pointer may be temporary and should not be stored for later use.
但窗口大小如果有变化则要重新建立
你应该获得你的invalidate rectangle,然后只绘制那里面的,这样会极大地缩小你需要绘制的内容