Article View: comp.windows.ms.programmer
Article #218Re: Setting BackGround Color of a window
From: Niels Erik Holm
Date: Wed, 08 Apr 1992 08:36
Date: Wed, 08 Apr 1992 08:36
44 lines
1664 bytes
1664 bytes
rpj@borland.com (Rich Johns) writes:
>Does anybody out there have a window class in which each instance
>of that class can have a different background color? I just can't believe
>such a thing can be so hard. I mean, its easy to change the bg for the
>entire class, but how can it be done on an instance basis?
>I've tried SetBkColor(...) and I've tried WM_ERASEBKGND, niether of which
>work. There must be a way to do this. I just can't believe that something
>so obviously useful, is so obscure.
Hi!
I think the SetBkColor applies only to text displayed with TextOut (or
a similar function). I've used the WM_ERASEBKGND message in the following
way:
/* Somewhere in the initialize section */
hBrush = CreateSolidBrush( BackGroundColor ); /* RGB value */
hOldBrush = SelectObject(hDC,hBrush);
/* In window procedure */
case WM_ERASEBKGND:
{
RECT ClipRct;
GetClipBox((HDC)wParam,&ClipRct);
FillRect((HDC)wParam,&ClipRct,hBrush);
/* Return TRUE because we DID erase the background */
return((LONG)TRUE);
}
break;
Fairly simple, I think.
Best regards
Niels Erik Holm
ICL DATA A/S (RC International)
Copenhagen, Denmark
neh@rci.dk
Technical Details
Message-ID:
<1992Apr08.083612.21839@rci.dk>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!swrinde!gatech!bloom-beacon!eru.mt.luth.se!lunic!sunic!dkuug!rcbal!nehReferences:
<1992Apr3.163234.26310@DMI.USherb.CA> <1992Apr3.172057.29585@borland.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!swrinde!gatech!bloom-beacon!eru.mt.luth.se!lunic!sunic!dkuug!rcbal!neh From: neh@rci.dk (Niels Erik Holm) Newsgroups: comp.windows.ms.programmer Subject: Re: Setting BackGround Color of a window Message-ID: <1992Apr08.083612.21839@rci.dk> Date: 8 Apr 92 08:36:12 GMT References: <1992Apr3.163234.26310@DMI.USherb.CA> <1992Apr3.172057.29585@borland.com> Organization: RC International, Copenhagen, Denmark Lines: 44