Using CBitmap object as a frame buffer

  • Thread starter Thread starter Safiullah
  • Start date Start date
S

Safiullah

Guest
This is in continuation of this thread

Trailing draws and clearing the Draw Region

So I am testing out the idea of drawing to a bitmap and then displaying it to the window frame in an MDI application.

However my Final BitBlt does not display anything. Code below:

void CFuncBlockTestView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
int dNetworkCompCount = 0, dNetworkWireCount = 0;
CBaseBlock * pLastComponent = nullptr;
CWire * pLastConnection = nullptr;
CRect rectDefaultRect(point.x-10, point.y-10, point.x+10, point.y+10);

CDC objMemDC;
CBitmap objBitmap;
CClientDC objClientDC(this);
CBrush objBkgnd(objClientDC.GetBkColor());

bool ret = false;

RECT rectClientRect;
unsigned int ret_val = 0;

OnPrepareDC(&objClientDC);

ret = objMemDC.CreateCompatibleDC(&objClientDC);
if (!ret) return;
ret = objBitmap.CreateCompatibleBitmap(&objMemDC, 2000, 2000);
if (!ret) return;
objMemDC.SelectObject(&objBitmap);
CPen objBlack(PS_SOLID, 1, RGB(0, 0, 0));
objClientDC.GetBoundsRect(&rectClientRect, DCB_RESET);
objMemDC.FillSolidRect(&rectClientRect, RGB(0, 0, 255));
objMemDC.SelectObject(objBlack);
objMemDC.Rectangle(0, 0, 200, 200);
objMemDC.Rectangle(point.x, point.y, point.x + 100, point.y + 100);
/*...*/
ret = objClientDC.BitBlt(0, 0, 2000, 2000, &objMemDC, 0, 0, SRCCOPY);
objBitmap.DeleteObject();
ReleaseDC(&objMemDC);

// CScrollView::OnMouseMove(nFlags, point);
}



I don't know if this is exactly how I would go about doing this.

Continue reading...
 
Back
Top