BUG: GP Fault When Drawing on a Memory-Based DC (111864)
The information in this article applies to:
- Microsoft Windows Software Development Kit (SDK) 3.1
This article was previously published under Q111864 SYMPTOMS
A general protection (GP) fault can occur on a memory-based device context
(DC) when a bitmap previously selected in the DC is selected out and
another is selected in. This is a common problem when using the SaveDC()
and RestoreDC() functions with a memory DC.
CAUSE
In a regular (nonmemory-based) DC, when the SaveDC() and RestoreDC()
functions are used, the size of the window client area of the DC does not
change. The size of the drawable area in a memory-based DC is dependent on
the size of the current bitmap selected in the DC.
For example, suppose the default 1 x 1 monochrome bitmap is selected in a
memory DC and you call SaveDC(). Now, you select a 200 x 200 color bitmap
into the DC and you perform some drawing commands. Then, you call
RestoreDC() to restore the DC. This action will select the old 1 x 1 bitmap
back into the DC. Unfortunately, GDI does not update the clipping region
when this happens, and when you draw outside the 1 x 1 region, you can
receive a GP fault.
RESOLUTION
After you call RestoreDC() on a memory-based DC, you need to call
SelectObject() to select the bitmap that was selected in the DC before
RestoreDC() was called.
STATUS
Microsoft has confirmed this to be a bug in Windows version 3.1. We are
researching this problem and will post new information here in the
Microsoft Knowledge Base as it becomes available.
Modification Type: | Major | Last Reviewed: | 11/6/1999 |
---|
Keywords: | KB111864 |
---|
|