🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #984

Re: Button Colors

#984
From: David D'SOUZA
Date: Thu, 27 Dec 1990 05:52
35 lines
2228 bytes
In article <21843@ttidca.TTI.COM> woodside@ttidcb.tti.com (George Woodside) writes:
>I've been unable to change the color of a button, created inside a
>window. I've followed the example in Petzold's book, and tried various
>other attempts, but the child button remains gray. The 'ybrush' handle
>is valid, and has been used successfully. "SPY" shows the messages are
>being received as expected, and debug logs show all values are as
>expected. But, the child buttons remain gray, instead of being painted
>yellow. Any help anyone can offer will be appreciated. The unsuccessful
>code segment:
>

Sorry, George, this is Windows biting you...  This is probably something
that should be included in the FAQ since it will bite first time windows
programmers since this example seems to appear in a lot of places...

Turns out in Windows 3.0, the button face is defined by two colors. The
grey (white if ega) face and a dark grey (grey if ega) shadow.  The
colors also change when the button goes from a normal to pushed in
state.  The WM_CTLCOLOR message only allows you to change one color at
a time so to which of the button face colors should this apply?
(Windows 2 button faces had only one color so it made sense.)

Maybe something tricky could have been done by using the background
color for the shadow and foreground color for the face and perhaps
doing something strange to get the text color in another way... And how
do you return 2 brushes (you now need a foreground and a background
brush)?  Or maybe even better, make colors a property of the window and
some windows could have multiple color properties...

Anyway, Windows doesn't look at the WM_CTLCOLOR message for buttons.  Try it
with a listbox instead...

--Dave

<Standard disclaimers apply>
Technical Details
Message-ID: <60067@microsoft.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!rutgers!usc!wuarchive!uunet!microsoft!davidds
References: <21843@ttidca.TTI.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!rutgers!usc!wuarchive!uunet!microsoft!davidds
From: davidds@microsoft.UUCP (David D'SOUZA)
Newsgroups: comp.windows.ms.programmer
Subject: Re: Button Colors
Message-ID: <60067@microsoft.UUCP>
Date: 27 Dec 90 05:52:26 GMT
References: <21843@ttidca.TTI.COM>
Reply-To: davidds@microsoft.UUCP (David D'Souza)
Organization: Microsoft Corp., Redmond WA
Lines: 35