PRB: RestoreDC() Fails Across Printer PagesID: Q139005
|
The RestoreDC() function returns failure when attempting to restore a printer Device Context (DC) that was saved by calling the SaveDC() function in Windows 95 version 4.0.
NOTE: This occurs only for applications marked as 4.0 applications.
RestoreDC() fails if the specified state instance does not exist on the GDI instance stack. Specifically, RestoreDC() fails on a printer DC if the StartPage() function is called between a call to the SaveDC() and a call to RestoreDC(). The RestoreDC() function fails because the StartPage() function in Windows 95 deletes any DC state instances that have been saved for that DC.
Applications use the StartPage() and EndPage() functions to indicate page separations on printer DCs. It is therefore necessary for applications written for Windows 95 to reinitialize a printer DC by selecting GDI objects and resetting mapping modes and other DC and GDI object attributes after every call to StartPage().
This behavior is by design.
When Windows 95-based applications print, they spool to Enhanced Metafile
(EMF) spool files by default. Spooling to an EMF requires a clean DC so
that each call to the StartPage() function restores the printer DC to its default state.
In addition to restoring the default state of the DC, Windows 95 also
empties the stack of DC states that may have been saved by calling the
SaveDC() function. This prevents applications from setting up a DC prior to a call to StartPage() and restoring the selected objects and attributes after the call to StartPage() with RestoreDC(). However, as long as the SaveDC() and RestoreDC() functions are called between StartPage()/EndPage() pairs, they will succeed and properly save and restore DC states for the printer DC.
Typically, applications should allocate GDI resources prior to the start of
a document or page and reuse these resources to initialize a printer DC at
the start of every page in a document.
Additional query words: 4.00 Windows 95 difference blank page output
Keywords : kbSDKWin32 kbWinOS95
Version : winnt:
Platform : winnt
Issue type : kbprb
Last Reviewed: June 15, 1999