PRB: Petzold's COLORS1 Sample Application Consumes ResourcesLast reviewed: July 23, 1997Article ID: Q85285 |
3.10
WINDOWS
kbprg kbprb kbcode
The information in this article applies to:
SYMPTOMSWhen the COLORS1 sample application on pages 227-232 of the book "Programming Windows 3" by Charles Petzold (Microsoft Press) is run under Windows 3.1, the amount of free system resources available after the program is complete is less than the amount available before running the program.
CAUSEThe program allocates system resources and does not free them.
RESOLUTIONMake the following modifications to the WndProc function in the COLORS1 sample:
MORE INFORMATIONIn both cases above, the call to DeleteObject fails because the brush is selected into a device context (DC). Each time the user moves one of the scroll bars, the program creates a new brush from the GDI module's heap space. Once the GDI heap reaches its limit of 64 kilobytes, none of the applications running in the system can create GDI objects. Under the debugging version of Windows 3.1, the following error message is displayed on the debugging terminal each time the erroneous code is executed:
err COLORS1 GDI: GDI:Attempt to delete object owned by systemThe resolution to this situation is to select a different brush into the DC, and then to delete the old brush. Because the SetClassWord function returns the previous value for the specified class word, it is very straightforward to pass the return value from SetClassWord to DeleteObject.
|
Additional reference words: 3.10
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |