wrong pagenumber

edited 10:00PM in FastReport VCL 5
Hello,
I've a problem with bands which switch to the next page.
The events fires on the previous page and the <page>-variable has the pagenumber from the previous page.

In our big formular the events before and after print fires on the wrong page.

In the sample I attached, the afterprint send the the correct pagenumber, but in the band is shown the wrong and the beforeprint fires on the first page.

Why is it so?
At FinalPass = true I thought that the bands are already created and so the pagenumber must be correct.

Greets Rene

Comments

  • gpigpi
    edited 10:00PM
    Use such script:
    var
      s : String;
    procedure MasterData2OnAfterPrint(Sender: TfrxComponent);
    begin
      if Engine.FinalPass then
        s:= s + #13#10 +'AfterPrint ' +Sender.Name+  ' - Page:' + IntToStr(<Page>);
    end;
    
    procedure MasterData2OnBeforePrint(Sender: TfrxComponent);
    begin
        if Engine.FinalPass then
          begin
            if Engine.FreeSpace <  Get('Line' + IntToStr(<Line#>)) then Engine.NewPage;          
            s:= s + #13#10 +'BeforePrint ' +Sender.Name+  ' - Page:' + IntToStr(<Page>);
          end;        
    end;
    
    procedure Page1OnAfterPrint(Sender: TfrxComponent);
    begin
      if s <> '' then
        showMessage(s);
    end;
    
    procedure PageFooter1OnBeforePrint(Sender: TfrxComponent);
    begin
    //  s := s + #13#10 + 'BeforeFoot ' + IntToStr(<Page>);
    end;
    
    procedure PageFooter1OnAfterPrint(Sender: TfrxComponent);
    begin
    //    s := s + #13#10 + 'AfterFoot ' + IntToStr(<Page>);
    end;
    
    procedure MasterData2OnAfterCalcHeight(Sender: TfrxComponent);
    begin
      if not Engine.FinalPass then Set('Line' + IntToStr(<Line#>), MasterData2.Height);                                    
    end;
    
    begin
    
    end.
    

Leave a Comment