Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

font color

edited December 2005 in General
Hi, I'm using Delphi 7 and Report Builder Enterprise 9.02.

I'm having trouble setting the TppLabel.Font.Color dynamically. When I
execute the following code, the line and the font are different colours.
The line colour is correct (blue) and the font is dark red. What am I
missing?

procedure TForm1.Button1Click(Sender: TObject);
var
lbl : Tpplabel;
rpt : TppReport;
line : TppLine;
begin
rpt := TppReport.create (self);
rpt.CreateDefaultBands;

lbl := TppLabel.Create(self);
lbl.Band := rpt.DetailBand;
lbl.left := 0;
lbl.Font.color := $004080;
lbl.font.Size := 8;
lbl.Alignment := taLeftJustify;
lbl.Font.Name := 'Tahoma';
lbl.Caption := 'blue text';

line := TppLine.Create(self);
line.position := lpTop;
line.ParentWidth := true;
line.Brush.Color := $004080;
line.Band := rpt.DetailBand;
line.top := 0.5;
line.Height := 0.25;

rpt.print;

end;

I also tried lbl.font.color := line.brush.color to no avail.

Sincerely,
Leah

Comments

  • edited December 2005
    Hi Leah,

    The Brush color of a line should have no effect on the actual line
    displayed. Are you certian the line is not black? In order to change the
    color of a line you will need to use the TppLine.Pen.Color Property.

    Both components us the Delphi TColor type to define their color. Note that
    in Delphi, when defineing colors using Hex values, the bits are reversed
    from that of a HTML color. For instance instead of Red, Green, Blue values
    in HTML, it is Blue, Green, Red values in Delphi. A bluish color would be
    $804000 in Delphi. Below is your code changed a bit...

    procedure TForm1.Button1Click(Sender: TObject);
    var
    lbl : Tpplabel;
    rpt : TppReport;
    line : TppLine;
    begin
    rpt := TppReport.create (self);
    rpt.CreateDefaultBands;

    lbl := TppLabel.Create(self);
    lbl.Band := rpt.DetailBand;
    lbl.left := 0;
    lbl.Font.color := $804000;
    lbl.font.Size := 8;
    lbl.Alignment := taLeftJustify;
    lbl.Font.Name := 'Tahoma';
    lbl.Caption := 'blue text';

    line := TppLine.Create(self);
    line.position := lpTop;
    line.ParentWidth := true;
    line.Pen.Color := $804000;
    line.Band := rpt.DetailBand;
    line.top := 0.5;
    line.Height := 0.25;

    rpt.print;

    end;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2005
    Oh, duh, thanks, it was black and your code works correctly.

This discussion has been closed.