nanogui: buttons of different colors


Previous by date: 18 Sep 2000 15:04:32 -0000 Can anyone tell me how to use CreateFontIndrect() under microwindows (i.e, win32 mwin part)?, liu hao
Next by date: 18 Sep 2000 15:04:32 -0000 More about keyboard not working, Alessandro Staltari
Previous in thread: 18 Sep 2000 15:04:32 -0000 buttons of different colors, Alfredo Macias
Next in thread:

Subject: Re: buttons of different colors
From: "Greg Haerr" ####@####.####
Date: 18 Sep 2000 15:04:32 -0000
Message-Id: <173a01c02181$f1775000$15320cd0@gregh>

: I need my app. to change the face color of a button on push-down.  As per
: win32, a BS_OWNERDRAW button style does this.  Since that has not been
: implemented yet, I'll devote some time in the next couple of days to
: implement it.  If anyone has made any effort at it please let me know.  If I
: succeed I'll send in a copy to the list.

Implementing BS_OWNERDRAW is a bit of work, and I don't
recommend it for something this simple.  I would suggest instead
that you work on a standard implementation of WM_CTLCOLORBTN,
which the control sends to its parent.  The button sends this before every
paint, I think.  When DefWindowProc receives this (or your own
parent WndProc) it could query the button with a BM_GETCHECK
message to see if it's pressed.  If so, you return the color you
want in a brush.  I've attached the reference for this message:


WM_CTLCOLORBTN

hdcButton = (HDC) wParam;   // handle of button display context
hwndButton = (HWND) lParam; // handle of button


The WM_CTLCOLORBTN message is sent to the parent window of a button when the
button is about to be drawn. By responding to this message, the parent window
can set a button's text and background colors.

Parameters

hdcButton

Value of wParam. Identifies the display context for the button.

hwndButton

Value of lParam. Identifies the button.

Return Value

If an application processes this message, it must return the handle of a brush.
Windows uses the brush to paint the background of the button.

Default Action

The DefWindowProc function selects the default system colors for the button.

Remarks

The WM_CTLCOLORBTN message is never sent between threads. It is sent only within
one thread.
The text color of a check box or radio button applies to the box or button, its
check mark, and the text. The focus rectangle for these buttons remains the
system default color (typically black). The text color of a group box applies to
the text but not to the line that defines the box. The text color of a push
button applies only to its focus rectangle; it does not affect the color of the
text.

You cannot use a custom palette to set a button's text or background color.
Although the SelectPalette and RealizePalette functions will succeed, they will
have no effect on the button.

Regards,

Greg


Previous by date: 18 Sep 2000 15:04:32 -0000 Can anyone tell me how to use CreateFontIndrect() under microwindows (i.e, win32 mwin part)?, liu hao
Next by date: 18 Sep 2000 15:04:32 -0000 More about keyboard not working, Alessandro Staltari
Previous in thread: 18 Sep 2000 15:04:32 -0000 buttons of different colors, Alfredo Macias
Next in thread:


Powered by ezmlm-browse 0.20.