From: Crispen, Bob (bob.crispen_at_boeing.com)
Date: 27 February 2003
Subject: Re: Window Background Color
Date: 20 Feb 2003 05:53:09 -0800
From: stewart.tootill_at_softel.co.uk (Stewart Tootill)
Organization: http://groups.google.com/
Newsgroups: comp.os.ms-windows.programmer.win32
"Tim Robinson" <tim_at_gaat.freeserve.co.uk@nowhere.com> wrote in
message news:<b317o0$1gctku$1_at_ID-103400.news.dfncis.de>...
> Chris <dhira_at_softhome.net> wrote:
> | I have a window with the background color set in WNDCLASS:
> | wc.hbrBackground = (HBRUSH) COLOR_WINDOW;
>
> This should be:
> wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
> or:
> wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
>
> The reason for the +1 is that, if hbrBackground is zero, Windows lets the
> window paint its own background. However, one of the COLOR_xxx constants is
> also zero. Adding one removes any confusion (Windows subtracts the 1
> internally).
MSDN says you should use the former. Dunno why, but it does. I assume it is because the window class calls deleteobject on the handle you give it at some point, and MSDN says that you should never call delete object on the handle returned by GetSysColorBrush (although you can for GetStockObject, odd that?)
This archive was generated by hypermail pre-2.1.8 : 26 April 2003 EDT