i'm trying print a window DC, but seems that i mistake on scale mode between HDC(pixels) and printer(?):(
the doc ins't printed... what i'm doing wrong on conversions?
Code:
void print()
{
//getting the default printer name
char szPrinterName[255];
unsigned long lPrinterNameLength;
GetDefaultPrinter( szPrinterName, &lPrinterNameLength );
//getting printer DC
HDC printerDC = CreateDC( "WINSPOOL",szPrinterName, NULL, NULL);
//starting doc and pages:
DOCINFO doc;
doc.cbSize = sizeof(DOCINFO);
doc.lpszDocName = "1st doc";
StartDoc(printerDC, &doc);
StartPage(printerDC);
//draw on printer using GDI functions
RECT windowRect;
GetClientRect(hwnd,&windowRect);
//SetMapMode(printerDC, GetMapMode(GetDC(hwnd)));
long width=GetDeviceCaps(printerDC,SCALINGFACTORX);
long height=GetDeviceCaps(printerDC,SCALINGFACTORX);
StretchBlt(printerDC,0,0,windowRect.right*width,windowRect.bottom*height,GetDC(hwnd),0,0,windowRect.right,windowRect.bottom,SRCCOPY);
//end pages and doc
EndPage(printerDC);
EndDoc(printerDC);
//delete the printer DC
DeleteDC(printerDC);
}