PRB: RestoreDC() Fails Across Printer Pages (139005)
The information in this article applies to:
- Microsoft Win32 Application Programming Interface (API), when used with:
This article was previously published under Q139005 SYMPTOMS
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.
CAUSERestoreDC() 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.
RESOLUTION
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().
STATUS
This behavior is by design.
MORE INFORMATION
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.
Modification Type: | Minor | Last Reviewed: | 3/21/2005 |
---|
Keywords: | kbprb KB139005 |
---|
|