views:

503

answers:

3

Does anybody know how to design report in FastReport so that when user changes page orientation all column headers and data autofits new page width? I couldn't find any anchor mechanism there. Maybe I can do that during run-time? But then I need to catch page orientation change event somehow. Can anybody help?

+1  A: 

You can :

  • use the Align property of each TfrxMemoview...
  • make it with Script
Hugues Van Landeghem
+1  A: 

I don't know what the question is: Bands are magnetic to page borders by default, so they fit the new page width.

But if you want the frxMemoview objects to move and resize according to the new page size, you should use the beforeprint event of the report to recalculate and move or size the report components.

If you have a report that can be printed both in portrait or landscape, the easiest way to buid this would be a layout for portrait and one for landscape. You could show a printersetupdailog before loading the report and depending on the orientation load the portrait or landscape layout.

This may not be the cleanest way. Building your report runtime in code is another option and recalculating every component in the report is another. But they involve a lot of coding and what if the user selects "Letter" instead of "A4"?

Regards, Teo FR dealer in Holland.

teo
I could calculate it programmatically, there probably is something like Page.Width property? I could use it to find the current page format. By the way, how can I call a print setup dialog? In Rave it is called by default, but there is no such dialog in FR, right? User can change page orientation when he has already started viewing report, but then I need to catch somehow an event of changing of page orientation. How can I do that?
Tofig Hasanov
A: 

Sometimes it is necessary to modify report page settings (for example, to modify paper alignment or size) from a code. The TfrxReportPage class contains the following properties, defining the size of the page:

   property Orientation: TPrinterOrientation default poPortrait;

   property PaperWidth: Extended;

   property PaperHeight: Extended;

   property PaperSize: Integer;

The «PaperSize» property sets paper format. This is one of the standard values, defined in the Windows.pas (for example, DMPAPER_A4). If a value to this property is assigned, FastReport fills the «PaperWidth» and «PaperHeight» properties automatically (paper size in millimeters). Setting the DMPAPER_USER (or 256) value as a format, would mean that custom paper size is set. In this case, the «PaperWidth» and «PaperHeight» properties should be filled manually.

The following example shows, how to modify parameters of the first page (it is assumed that we already have a report):

Pascal:

var
Page: TfrxReportPage; 
{ the first report’s page has [1] index. [0] is the Data page. } 
Page := TfrxReportPage(frxReport1.Pages[1]);  
{ modify the size } 
Page.PaperSize := DMPAPER_A2;   
{ modify the paper orientation }  
Page.Orientation := poLandscape;

C++:

TfrxReportPage * Page;
// the first report’s page has [1] index. [0] is the Data page. 
Page = (TfrxReportPage *)frxReport1.Pages[1];
// modify the size 
Page->PaperSize = DMPAPER_A2;
// modify the paper orientation 
Page->Orientation = poLandscape;
Mohammad Arshadtehrani