Dear Friends,
I got following code from expert-exchange.com for convert displayed drawing from OnDraw(CDC *pDC) to BMP file
void CCheckView::OnFileSave()
{
// TODO: Add your command handler code here
CDC * pdcMemory = new CDC;
CWnd *pWnd=new CWnd;
CRect rect;
pWnd->GetWindowRect(rect);
CBitmap * pBitmap = new CBitmap;
if (pdcMemory->GetSafeHdc() == NULL) {
CClientDC dc(this);
OnPrepareDC(&dc);
pBitmap->CreateCompatibleBitmap(&dc, 300, 300);
pdcMemory->CreateCompatibleDC(&dc);
pdcMemory->SelectObject(pBitmap);
pdcMemory->FillSolidRect(0, 0, 300,300,RGB(255, 255, 255)); // manully paint it white
OnDraw(pdcMemory);
WriteWindowToDIB(".\\test.bmp", pWnd);
}
delete pdcMemory;
delete pBitmap;
}
In the above code, while running pWnd->GetWindowRect(rect); giving run-time error.
Please help me to clear my doubts.
With warm regards
-Mahesh