Steps to Send a Document to a PrinterLast reviewed: January 5, 1995Article ID: Q75339 |
The information in this article applies to:
SUMMARYIf code simplicity is more desirable than printing efficiency, an application can implement printing with almost no additional code. For this discussion, the application defines a DrawStuff procedure that renders text and/or graphics into a specified display context. The application can render the image to the screen by getting a screen display context and passing its handle to DrawStuff(). Printing is more involved; the seven steps required are detailed below.
// // HDC GetPrinterDC(void) // // Return a DC to the currently selected printer. // Returns NULL on error. // HDC GetPrinterDC(void) { static char szPrinter[64]; char *szDevice, *szDriver, *szOutput; GetProfileString("windows", "device", "", szPrinter, 64); if ((szDevice = strtok(szPrinter, "," )) && (szDriver = strtok(NULL, ", ")) && (szOutput = strtok(NULL, ", "))) return CreateDC(szDriver, szDevice, szOutput, NULL); return NULL; }
szJobName = "<job name>"; Escape(hDC, STARTDOC, lstrlen(szJobName), szJobName, NULL); [3.5. In Windows 3.1 and later, call StartPage() to begin a page.]
Escape(hDC, NEWFRAME, 0, 0L, 0L); (If more than one page is printed, repeat steps 4 and 5 for each page.)
Escape(hDC, ENDDOC, 0, 0L, 0L);
DeleteDC(hDC); Printing requires little extra work if the drawing code is modular. The drawback to the approach above is that it can require more memory and printing time than may otherwise be necessary. For more information on speeding the printing process, query on the following words in the Microsoft Knowledge Base:
prod(winsdk) and printing and banding |
Additional reference words: 3.00 3.10
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |