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

Set font at runtime

edited July 2003 in General
I've seen the tech-tip for looping through all report objects at runtime,
but where do I call the code from? I've tried it in the "BeforePrint"
event, but it doesn't work there. I've also tried it after generating the
report, then calling "refresh" with no luck.

I'm using a report hooked up to the TppViewer control, and generating the
report calling TppViewer.RegenerateReport.

Comments

  • edited July 2003
    Can you do it before calling .Print? otherwise, what does your code look
    like?

    --
    Ed Dressel
    Team DM
  • edited July 2003
    I wasn't calling .Print. I'm using a TppViewer, and I'm just calling
    TppViewer.RegerateReport.

    Actually, I figured out a way to get it to work. At form creation, I call
    this:

    procedure setupReportFont(aControl: TControl);
    var
    repeats: Integer;
    begin
    for repeats := 0 to aControl.ComponentCount - 1 do
    begin
    if aControl.Components[repeats] is TppComponent then
    begin
    if TppComponent(aControl.Components[repeats]).HasFont then
    begin
    TppComponent(aControl.Components[repeats]).Font.Name :=
    'Default';
    TppComponent(aControl.Components[repeats]).Font.Charset :=
    DEFAULT_CHARSET;
    end;
    end;
    end;
    end;

    So, in my "FormCreate" event, I just call setupReportFont(self), and it
    changes any descendant of TppComponent. Then, when I print my report,
    everything has the font I want.
This discussion has been closed.