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

How to read zoomPercentage

edited May 2003 in General
Is there a way to read the zoomPercentage of a form outside the
OnPreviewFormCreate event?

I am able to set the zoomSetting (and zoomPercentage) in the
OnPreviewFormCreate event using

with myReport.Previewform do
begin
formStyle := fsMDIChild;
TppViewer(Viewer).zoomSetting := zs100Percent;
end;

I want to be able to record a users zoomSetting for later reuse.

Is there a type cast to allow

with (MDIChildren[0] as ????).PreviewForm do
begin
myZoomPercentage := TppViewer(Viewer).zoomPercentage;
end;

Thanks

Russell

Comments

  • edited May 2003
    Same question: ...

    TppReport(MDIChildren[0].Owner as
    TppReport).PreviewFormSettings.zoomPercentage always reports 100
    even when in the OnPreviewFormCreate event the zoomSetting is set to
    zsPercentage, even when the user has changed the zoomPercentage.

    I am trying to find the zoomPercentage after a user may have changed it, so
    I can give the zoomPercentage that value, if the user wants it, the next
    time the report is invoked.

    Thanks

    Russell

  • edited May 2003
    Hi Russell,

    I doubt that 'MDIChildren[0].Owner' will be your report component.
    You have to detect the report component first, then you can use the following code ...
    myZoomSetting := TppViewer(myReport.PreviewForm.Viewer).ZoomSetting;

    regards,
    Chris Ueberall;
  • edited May 2003
    Hello Chris

    Thanks for your reply. I am looking for ZoomPercentage, but the code to read
    these values you suggest should work for both.
    Here is the code which works:

    if ((MDIChildren[0].Owner as TppReport).inheritsFrom(TppReport)) then

    begin

    myZP := TppViewer(TppReport(MDIChildren[0].Owner as
    TppReport).PreviewForm.Viewer).zoomPercentage;

    end;


    Thanks

    Russell

  • edited May 2003
    Correction:
    myZP :=
    TppViewer(TppReport(MDIChildren[0].Owner).PreviewForm.Viewer).CalculatedZoom
    ;
    should be used to get the zoomPercentage. the property "zoomPercentage" is
    not updated when a user changes the zoomPercentage.

    Russell


  • edited May 2003
    Russell,

    when the user changes the zoom percentage the property will be updated.
    Be aware, that property 'ZoomPercentage' is only valid when property 'ZoomSetting' is 'zsPercentage'.
    Yes it would nice when property 'ZoomPercentage' would be updated for the other settings too (I did my test with RB 5.6, this may have been changed in the current version). But re-using the last zoom settings should be of no problem then.

    HTH,
    Chris Ueberall;
This discussion has been closed.