The information in this article applies to:
SUMMARYAn application can change the colors of a dialog box by creating a brush of the desired color and processing the WM_CTLCOLOR message to return a handle to the brush. If the brush is not a stock object, the application should create the brush before the dialog box is displayed and store its handle in a global or static variable. Do not use the following code in a dialog box procedure:
Windows sends a WM_CTLCOLOR message to the dialog box procedure each
time any changes are made to the dialog box (such as when the user
presses a button or moves the focus to a new control). In the code
above, each time the application processes a WM_CTLCOLOR message for
an edit control, the application creates a new brush which is stored
in the GDI data segment. If the GDI data segment fills completely,
Windows generates a FatalExit 0x0001 (insufficient memory for
allocation) error for each subsequent allocation.
MORE INFORMATION
To avoid this error, modify the application to call the
CreateSolidBrush function once, either outside the application's
message loop or during the processing of the WM_CREATE message. Store
the returned brush handle in a global or static variable. An advantage
of this method is that the brush can be used in any part of the
application without consuming any additional system resources.
Additional query words:
Keywords : kb16bitonly kbDlg kbSDKPlatform kbGrpUser |
Last Reviewed: November 3, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |