Sudeer had asked about button colours and in one of my posts I said that I preferred a custom control to do that task.

Here is a very simple custom control that gives seperate UP and DOWN colour control.

The control is really in its beta stage but it seems to be working OK. It has a simplified logic that shows when you hold the mouse button down, the button stays down, even when the mouse is not within the button's rectangle.

As I get time, I will add font selection to it via WM_SETFONT message and perhaps text colour control as well.

Posted on 2002-03-04 04:52:49 by hutch--
Thank you for the effort, but the question is, how do you change the button color by using WM_CTLCOLORBTN when i have three buttons in a dialog box.
thanks a lot
Posted on 2002-03-07 03:14:58 by sudeer

With this control rather than the standard one, you change the colour by using the following code.

invoke SetWindowLong,hButn,0,hBrush1 ; butn up colour
invoke SetWindowLong,hButn,4,hBrush2 ; butn down colour

The handle is the one you get from the control's return value, the next number is the offset and the last is the brush which you must create.

Basically you change either or both brushes then use InvalidateRect() to force the repaint.

When I get a bit more time I will make this control a bit more user friendly in term of programming it. At the moment it will do the job if you understand how the code works.

Posted on 2002-03-07 08:07:26 by hutch--
let us try an example as you said, it is going to be much...much better
Thanks again
Posted on 2002-03-08 01:11:12 by sudeer