Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button color

Status
Not open for further replies.

jrdoner

Programmer
Jul 17, 2003
4
I find that the Object Editor does not allow for changing the color of a button. This seems rather odd, since I would like to make buttons, say, red or green, depending on state, just like power buttons on hardware. So how does one specify the color of a button?

Thanks in advance for any tips.

John Doner
 
There are several coloured button components out there, most have more functionality than just the colour, look at how these are coded, and consider writing your own coloured button component (dont just copy the code that could be breaking the authors terms of use.)

The basic difference is that you have to be able to paint on the canvas of the button, standard TButton doesnt have this facility.

There is a lot more to this but to show the colouring process this is simplified from someones button component!!

Code:
var Region: HRgn;
begin 
 Canvas.Brush.Color := RGB(R, G, B);
 FRgn := CreateRectRgn(n, n, Width-n, Height-n);

 try
   FillRgn(Canvas.Handle, Region, Canvas.Brush.Handle);
 finally
   DeleteObject(Region);
 end;



Steve: Delphi a feersum engin indeed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top