?
Sorry, dass ich erst so spät schreibe, hatte bis jetzt keine Zeit...
Also hier ist mein Code, den ich aus VCPP in 21 Tagen und einem Beitrag im Forum von Codeguru zusammengebastelt habe:
CPrintDialog dlgPrint(FALSE,PD_ALLPAGES,this);
if (dlgPrint.DoModal()==IDOK){
// Den Drucker-DC vom Dialogfeld mit einem
// CDC-Objekt verbinden
CDC dcPrint;
dcPrint.Attach(dlgPrint.GetPrinterDC());
// Eine DOCINFO-Struktur erzeugen und füllen
DOCINFO myPrintJob;
myPrintJob.cbSize = sizeof(myPrintJob);
myPrintJob.lpszDocName = "Programmname";
myPrintJob.lpszOutput = NULL;
myPrintJob.lpszDatatype = NULL;
myPrintJob.fwType = NULL;
// Ausdruck des Dokuments starten
if (dcPrint.StartDoc(&myPrintJob)>=0)
{
// Eine Seite beginnen
dcPrint.StartPage();
// 1. Load the bitmap with CBitmap::LoadBitmap()
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP);
// get the bitmap's size
BITMAP BM;
bmp.GetObject(sizeof(BM),&BM);
long lBmpHeight = BM.bmHeight;
long lBmpWidth = BM.bmWidth;
// 2. Create a memory device context, compatible to the screen
CDC memDC;
memDC.CreateCompatibleDC(&dcPrint);
// 3. Select the bitmap into it with CDC::SelectObject()
CBitmap* pOldBitmap = memDC.SelectObject(&bmp);
// 4. Blit (or stretch-blit) the mem-DC into the printer-DC
dcPrint.StretchBlt(0,0,500,500,&memDC,0,0,lBmpHeight,lBmpWidth,SRCCOPY);
// 5. deselect the bitmap from the mem-DC
memDC.SelectObject(pOldBitmap);
// 6. destroy the bitmap and the mem-DC
bmp.DeleteObject();
memDC.DeleteDC();
// Seite auswerfen
dcPrint.EndPage();
// Dokument schließen
dcPrint.EndDoc();
}
// Druckergerätekontext löschen
dcPrint.DeleteDC();
}
Weiß jemand, wo der Fehler liegt?
greetz tompo