how to Call PrintPageSetup

edited February 2018 in FastReport 4.0
hi

after frxreport.showreport I can click pagesetup toolbutton on toolbar to set paper size ,but how can i to change page size in code (call that pageSetup dialog)?

Comments

  • gpigpi
    edited 4:07AM
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, frxClass, frxPreview, frxPreviewPageSettings;
    
    type
      TForm1 = class(TForm)
        frxReport1: TfrxReport;
        procedure FormCreate(Sender: TObject);
        procedure frxReport1Preview(Sender: TObject);
        procedure NewOnClick(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
         frxReport1.PreviewPages.LoadFromFile('штатное.fp3');
         frxReport1.ShowPreparedReport;
    end;
    
    procedure TForm1.NewOnClick(Sender: TObject);
    var
      APage: TfrxReportPage;
      i: integer;
    begin
      if frxReport1.Engine.Running then Exit;
      APage := frxReport1.PreviewPages.Page[TfrxPreview(frxReport1.Preview).PageNo - 1];
    
      if Assigned(APage) then with TfrxPageSettingsForm.Create(Application) do
      begin
        Page := APage;
        Report := frxReport1;
        if ShowModal = mrOk then
        begin
          if NeedRebuild then
          begin
           try
             frxReport1.Preview.Lock;
             for i := 0 to frxReport1.PreviewPages.Count - 1 do
              begin
                with TfrxReportPage(frxReport1.PreviewPages.Page[i]) do
                 begin
                  Orientation := APage.Orientation;
                  PaperWidth := APage.PaperWidth;
                  PaperHeight := APage.PaperHeight;
                  PaperSize := APage.PaperSize;
    
                  LeftMargin := APage.LeftMargin;
                  RightMargin := APage.RightMargin;
                  TopMargin := APage.TopMargin;
                  BottomMargin := APage.BottomMargin;
                 end;
                frxReport1.PreviewPages.ModifyPage(i , frxReport1.PreviewPages.Page[i]);
              end;
           finally
             frxReport1.Preview.Unlock;
          end;
          end
          else
          begin
            try
              frxReport1.Preview.Lock;
              frxReport1.PreviewPages.ModifyPage(TfrxPreview(frxReport1.Preview).PageNo - 1, Page);
            finally
              frxReport1.Preview.Unlock;
            end;
          end;
        end;
        Free;
      end;
    end;
    
    procedure TForm1.frxReport1Preview(Sender: TObject);
    begin
       if frxReport1.PreviewForm is TfrxPreviewForm then
        begin
         TfrxPreviewForm(frxReport1.PreviewForm).PageSettingsB.OnClick := NewOnClick;
        end;
    
    end;
    
    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.