Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Save Preview Form Settings Per User

edited May 2010 in General
Hello,

My app has hundreds of reports of different sizes and different page
orientations. Of course, the users have monitor sizes and resolutions of
all types. The users would like my app to save their preview form zoom
settings so that when they preview a report they don't need to change the
zoom settings each time.

Is there a way I can use an event in my custom preview plugin to a) save the
current zoom setting for the user when the preview window closes, and b) the
next time that same report is previewed, set the zoom setting to the value
saved in a)?

I'm using 10.04 Enterprise, but will be upgrading to version 12 very soon.

Thanks,

Mike Fitzgerald



__________ Information from ESET Smart Security, version of virus signature database 5151 (20100527) __________

The message was checked by ESET Smart Security.

http://www.eset.com

Comments

  • edited May 2010
    Yes, you can :-)

    FYI I have an object, FReportSetup, that persists the settings for the
    client. It is in the code snippets below.

    For the TppReport object, use the OnPreviewFormCreate and
    OnPreviewFormClose. In the OnPreviewFormCreate, assign something similar to
    the following:

    procedure TfrmMaster.CreatePrintPreviewForm(Sender: TObject);
    var
    lPF: TMyPrintPreview;
    begin
    Assert(Sender is TppCustomReport);
    Assert(TppCustomReport(Sender).PreviewForm is TMyPrintPreview);

    lPF := TppCustomReport(Sender).PreviewForm as TMyPrintPreview;
    lPF.OnShow := PrintPreviewFormShow;

    if FReportSetup.AssignMainFormSize then // an option in my software
    lPF.Position := poDefault;
    end;

    procedure TfrmMaster.PrintPreviewFormShow(Sender: TObject);
    var
    lPF: TMyPrintPreview;
    lViewer: TppViewer;
    begin
    Assert(Sender is TMyPrintPreview);

    lPF := Sender as TMyrintPreview;
    if FReportSetup.AssignMainFormSize then
    begin
    //this is called in my main form--use your own code here
    lPF.WindowState := WindowState;
    lPF.SetBounds(Left, Top, Width, Height);
    end
    else
    begin
    lPF.SetBounds(FReportSetup.PreviewFormLeft, FReportSetup.PreviewFormTop,
    FReportSetup.PreviewFormWidth, FReportSetup.PreviewFormHeight);
    lPF.WindowState := FReportSetup.PreviewWindowState;
    end;
    lPF.DisplayDocumentName := True;
    lPF.Preview.OutlineVisible := FReportSetup.OutlineVisible;

    lViewer := TppViewer(lPF.Viewer);
    lViewer.ZoomSetting := TppZoomSettingType(FReportSetup.PreviewPageView);
    if lViewer.ZoomSetting = zsPercentage then
    lViewer.ZoomPercentage := FReportSetup.PreviewPagePercent;
    end;

    and then in the close, use the following code


    procedure TfrmMaster.ClosePrintPreviewForm(Sender: TObject);
    var
    lPF: TMyPrintPreview;
    lViewer: TppViewer;
    begin
    lPF := TppCustomReport(Sender).PreviewForm as TMyPrintPreview;
    lViewer := TppViewer(lPF.Viewer);

    FReportSetup.OutlineVisible := lPF.Preview.OutlineVisible;
    FReportSetup.PreviewWindowState := lPF.WindowState;
    FReportSetup.PreviewFormHeight := lPF.Height;
    FReportSetup.PreviewFormWidth := lPF.Width;
    FReportSetup.PreviewPagePercent := lViewer.ZoomPercentage;
    FReportSetup.PreviewPageView := Ord(lViewer.ZoomSetting);
    end;

    HTH,
    Ed Dressel
    Team DM


    In your custom preview form, be sure to the TppCustomPreview object (called
    "Preview" in my code below). Then the code in the PreviewFormShow would l
    Then the code is going to look something like this
This discussion has been closed.