25 - Improvement
    On this chapter, we will add functionalities to our basic example in order to determine a maximum of case.

    25.1 - Printing on line:

    You must add a TButton component with the property CAPTION: = ' To print ' and TPrintDialog (pallet standard of DELPHI dialogues) and to obtain thas:
    Add also the Printers unit to the clause USE of your card and enter the following code to onClick event of the button " To print " which I named bPrint.
     
     
    TForm1.bPrintClick(Sender procedure: TObject); 
    VAr FromPg, ToPg, Cpy: Integer; 
         ind: Integer; 
         St: String; 
         Collap: Boolean; 
    begin
     / / Load the state
      St:=ExtractFilePath(ParamStr(0)); 
     frReport1.LoadFromFile(St+' rap1.frf'); 

      / / Changing the default printer 
     ind: = Printer.PrinterIndex; 
      / / Prépare the state, to leave if the preparation did not function
      Yew Not frReport1.PrepareReport then Exit; 

      / / Initialise limps it of dialogue for paramètrer the edition
      with PrintDialog1 C
      begin
       Options:=[poPageNums ]; / / Authorizes the selection of pages
       Copies: = 1;       / / Only one specimen
       Collate: = True;     / / sorted Copies
       FromPage: = 1;     / / Page of beginning
       ToPage: = frReport1.EMFPages.Count;  / / Last page, by defect totality
       MaxPage: = frReport1.EMFPages.Count; / / a Number of maximum pages, by defect totality
        yew Execute then    / / Exécution of limps of dialogue
        begin
          was yew Printer.PrinterIndex < > ind then  / / there a change of printer?
           does yew frReport1.CanRebuild then    / / owe one regénérer the state?
             yew frReport1.ChangePrinter(ind, Printer.PrinterIndex) then / / Change of printer
               frReport1.PrepareReport 
             else exit; / / the change of printer badly occurred

          yew PrintDialog1.PrintRange = prPageNums then / / one made a selection of pages
          begin
           FromPg: = PrintDialog1.FromPage; / / first page
           ToPg: = PrintDialog1.ToPage;      / / last page
          end;

         Cpy:=PrintDialog1.Copies;   / / a Number of copies
         Collap:=PrintDialog1.Collate;  / / Exemplary sorted

          / / Lance the edition of the page " FromPg " with " ToPg ", " Cpy " exmplaires sorted (Collap))
         frReport1.PrintPreparedReport(FromPg, ToPg, Cpy, Collap); 
        end;
      end;
    end;

    It is a little bit long but nothing prevent yourself to create a class inheriting from TFrReport with a Print method or easier, to create a procedure " PrintReport(letat: string) " which load the report and printing it.
     
    25.2 - Possible options:
      25.21 - Options of page

         You obtain these options with the editor menu : " File " then " Page options... ". You obtain this:
       

      • For setting the paper size.

         
      • To set edges

         
      • For the various options


                 Here, you specify the number of columns as well as space between the columns.
       


         
      25.22 Options on the state

      With the principal menu of the editor, select " File " then " Report options" to display the following dialog box :

         

             
      Here, you specify the printer which is necessary to select during the loading of the state and if the preparation is done on the two ways.
       
       
      Warning : if you want to number your pages with  " current Page " from "Number of total page ", you must notch the option "Two-pass report"


        Previous page                    next Page                 Contents