|
-
April 15th, 2004, 04:02 AM
#1
Printing Error
Hi,
I get "memory couldnot be read" error at StartDoc().
Here is my code, can anyone tell me why this error occurs.
Thank you and regards,
Salil.
void CAprsView::Onfileprint()
{
// TODO: Add your command handler code here
CPrintDialog dlg(FALSE);
if(dlg.DoModal()) {
BOOL b = InitBmpData(); // combines 5 bitmaps and creates one large bitmap.
dlg.GetDefaults();
HDC hdcPrinter = dlg.GetPrinterDC();
if(hdcPrinter == NULL) {
MessageBox(_T("Printer Not Found"));
}
else {
CDC dcPrinter;
dcPrinter.Attach(hdcPrinter);
////////////////////////////////////////////
CDC dcMem;
dcMem.CreateCompatibleDC(&dcPrinter);
CBitmap* pOldBmp = dcMem.SelectObject(&m_BmpLarge);// holds the large bmp
////////////////////////////////////////////
DOCINFO docinfo;
memset(&docinfo,0,sizeof(&docinfo));
docinfo.cbSize = sizeof(docinfo);
docinfo.lpszDocName = _T("Bitmap");
if(dcPrinter.StartDoc(&docinfo) < 0) { // error at this step, memeory cannot be read.
MessageBox(_T("Printer did not initialize"));
} else {
if(dcPrinter.StartPage() < 0) {
MessageBox(_T("Could not start page"));
dcPrinter.AbortDoc();
} else {
dcPrinter.BitBlt(0,0,len_in_pix,ht_in_pix, &dcMem,0,0,SRCCOPY);
}
}
dcPrinter.EndPage();
dcPrinter.EndDoc();
////////////////////////////////////////////
dcMem.SelectObject(pOldBmp);
////////////////////////////////////////////
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|