There are lots of information out there on how to change the color of a
TButton, just do a Google search.  But anyways, one of the way you can color
a button is to create your own TButton control and trap the WM_PAINT
message.


WMPaint....
var
  ControlCanvas :TControlCanvas;
  aRect :TRect;
begin
  inherited ...

  ControlCanvas:= TControlCanvas.Create;
  try
    ControlCanvas.Control:= Self;
    ControlCanvas.Brush.Color:= clGreen;
    aRect:= ClientRect;
    aRect:= Rect(2, 2, Width-2, Height-2); //leave the 3D effect
    ControlCanvas.FillRect(aRect);
    aRect:= Button1.ClientRect;
    DrawText(ControlCanvas.Handle, PChar(Caption), Length(Caption), aRect,
       DT_CENTER + DT_VCENTER + DT_SINGLELINE);
  finally
    ControlCanvas.Free;
  end;
end;

Note:
  You also need to draw the focus rectangle your self when the control
recieves focus.


Hope this helps
_______________________
Allan D. Vergara
Software Engineer
Niche Software Ltd
http://www.WorkPace.com



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Stephen Bertram
Sent: Friday, 31 October 2003 8:10 AM
To: Multiple recipients of list delphi
Subject: [DUG]: Colouring TListbox Headers


Hi All

Can anyone give me a quick pointer on how to change the colour of TButton
and the column headers in TListBox? I know there are third party components,
but there are reasons why I want to use the basic windows controls.

I'm using Delphi 5.

TIA

Stephen
Disclaimer : This communication contains information that is confidential
and the copyright of ensynergy Limited or a third party. If you are not the
intended recipient of this communication please delete and destroy all
copies and telephone ensynergy Limited on +64 9 3551591 immediately. If you
are the intended recipient of this communication you should not copy,
disclose or distribute this communication without the authority of ensynergy
Limited. Any views expressed in this communication are those of the
individual sender, except where the sender specifically states them to be
the views of ensynergy Limited. Except as required by law, ensynergy Limited
does not represent, warrant and/or guarantee that the integrity of this
communication has been maintained nor that the communication is free of
errors, virus, interception or interference.

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to