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

Preventing Orphans by measuring length of stretched Controls

edited May 2002 in General
I am trying to prevent a summary band being an "orphan" at the end of my
report.

The report has a static memo, then a TppRichtext control that can stretch
and cover many pages and finally another static memo. There are page headers
and footers too, but that is not key to my problem.

The contents of the RichText varies in length (read from a stream).
Sometimes the length is such that the following final memo ends up at the
top of a new page - an orphan. What I would like to do is be able to judge
that this will happen and adjust the position of the top of the RichText
control so that some of the RichText overflows onto that final page and
keeps the final memo company.

How can I do this? What will give me the total length of the stretched
RichText? What events could I successfully put this kind of processing in?

Suggestions?

Sarah

Comments

  • edited May 2002
    Set the report to two pass. Implement the the DrawCommandCreate event
    handler of the memo and of the richtext. Check the printing position of the
    memo on the page. If the position is to high, reposition the richtext. For
    example:

    procedure TForm1.ppMemo2DrawCommandCreate(Sender, aDrawCommand: TObject);
    begin
    if ppReport1.FirstPass and (TppDrawCommand(aDrawCommand).Top <
    aMinimumValue) then
    FRepositionRichText := True;
    end;

    procedure TForm1.ppRichText1DrawCommandCreate(Sender, aDrawCommand:
    TObject);
    begin
    if ppReport1.SecondPass and FRepositionRichText then
    TppDrawCommand(aDrawCommand).Top := TppDrawCommand(aDrawCommand).Top +
    aOffset;
    end;

    Keep in mind that the Top property of the draw command is in thousands of a
    millimeter.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

This discussion has been closed.