wrong pagenumber

edited 3:27AM 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 3:27AM
    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

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.