[comp.windows.ms.programmer] Control class colors

dpelland@hawk.ulowell.edu (David Pelland) (05/04/91)

Hello,

	Could someone please enlighten me as to how I can set
	the background color of a control class window.  I've
	tried doing it at creation time, and by processing the
	WM_CTLCOLOR message.  I must be doing something wrong.
	Any help is appreciated.

	All I wanted was a red button... :(

Thanks
	Dave Pelland

curt@cctb.wa.com (Curt Johnson) (05/08/91)

In article <1991May3.213512.7371@ulowell.ulowell.edu> dpelland@hawk.ulowell.edu (David Pelland) writes:
| 	Could someone please enlighten me as to how I can set
| 	the background color of a control class window.  I've
| 	tried doing it at creation time, and by processing the
| 	WM_CTLCOLOR message.  I must be doing something wrong.
| 	Any help is appreciated.
| 
| 	All I wanted was a red button... :(

Sorry, you can't do it.

All windows will let you change is the color the button
procedure uses for the WINDOW background, this color is
placed in 1 pixel in each corner of the button (to give
it a somewhat rounded look).


Curt Johnson == curt@cctb.wa.com

bonneau@hyper.hyper.com (Paul Bonneau) (05/08/91)

In article <917360id@cctb.wa.com> curt@cctb.wa.com (Curt Johnson) writes:
>In article <1991May3.213512.7371@ulowell.ulowell.edu> dpelland@hawk.ulowell.edu (David Pelland) writes:
>| 	Could someone please enlighten me as to how I can set
>| 	the background color of a control class window.  I've
>| 	tried doing it at creation time, and by processing the
>| 	WM_CTLCOLOR message.  I must be doing something wrong.
>| 	Any help is appreciated.
>| 
>| 	All I wanted was a red button... :(
>
>Sorry, you can't do it.
>
>All windows will let you change is the color the button
>procedure uses for the WINDOW background, this color is
>placed in 1 pixel in each corner of the button (to give
>it a somewhat rounded look).
>
This is simply not true.  While setting the background brush
may not be enough (depends on the control), you can still
call SetBkColor(wParam, your_color_here) when you get the
WM_CTLCOLOR message.

Also, there is no problem returning a brush handle from a
dialog proc (even though the docs imply that only 0 or
non-zero are significant).

BTW, it sounds like your response is for a windows version
*2* PushButton!

cheers - Paul Bonneau.

cms2839@isc.rit.edu (a.stranger) (05/09/91)

In article <917360id@cctb.wa.com> curt@cctb.wa.com (Curt Johnson) writes:
>In article <1991May3.213512.7371@ulowell.ulowell.edu> dpelland@hawk.ulowell.edu (David Pelland) writes:
>| 	Could someone please enlighten me as to how I can set
>| 	the background color of a control class window.  I've
>| 	tried doing it at creation time, and by processing the
>| 	WM_CTLCOLOR message.  I must be doing something wrong.
>| 	Any help is appreciated.
>| 
>| 	All I wanted was a red button... :(
>
>Sorry, you can't do it.
>
>All windows will let you change is the color the button
>procedure uses for the WINDOW background, this color is
>placed in 1 pixel in each corner of the button (to give
>it a somewhat rounded look).
>

				actually , you could probably do it with
an owner_draw button , if you really wanted it .
-- 
       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
       @     "Imagination keeps the shadows away  -  Xymox      @
       @~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@
       @       a.stranger  -  CMS2839@ritvax.isc.rit.edu        @

risto@tuura.UUCP (Risto Lankinen) (05/09/91)

curt@cctb.wa.com (Curt Johnson) writes:

>In article <1991May3.213512.7371@ulowell.ulowell.edu> dpelland@hawk.ulowell.edu (David Pelland) writes:
>| 	Could someone please enlighten me as to how I can set
>| 	the background color of a control class window.  I've
>| 	tried doing it at creation time, and by processing the
>| 	WM_CTLCOLOR message.  I must be doing something wrong.
>| 	Any help is appreciated.
>| 
>| 	All I wanted was a red button... :(

Hi!

If the control were made (or changed) to have BS_OWNERDRAW style, its parent
will start receiving WM_DRAWITEM messages.  By responding to that message,
the button can be painted however one likes.

The lParam of the WM_DRAWITEM points to a DRAWITEMSTRUCT, one field of which
is the hDC of the button.  You will have to paint the button by yourself
altogether, which means that you'll lose the 3D'ity unless you paint it that
way.

I've used the owner draw buttons, and I solved the problem by designing a few
icons to represent the normal/clicked/selected status, which had the 3D look,
and then drew the corresponding icon in response to the WM_DRAWITEM .  Using
prepainted icons has a drawback in that their color cannot be easily changed
should the ButtonFace setting in WIN.INI be non-default, but if you want it
red, then I guess that matters not much...

Terveisin: Risto Lankinen
-- 
Risto Lankinen / product specialist ***************************************
Nokia Data Systems, Technology Dept *  2                              2   *
THIS SPACE INTENTIONALLY LEFT BLANK * 2 -1 is PRIME!  Now working on 2 +1 *
replies: risto@yj.data.nokia.fi     ***************************************