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

6.01 and Preview

edited August 2001 in General
In the previous release a change the preview unit to position and size the
preview form in the form.oncreate event and I save the last position and
size in the form.onclose event.
With the new preview form an a setup the position as show in the help file.

But can I access the previw.onclose event ?

My updated preview form still seems to works fine with the new release. If I
can not access the form.onclose event, do I miss anything when I use the old
preview unit ?

Albert Kessler

Comments

  • edited August 2001
    There is the OnPreviewFormClose and OnPreviewFormCreate events of the Report
    component.

    You should be able to access the form like this:


    procedure TForm1.ppReport1PreviewFormClose(Sender: TObject);
    begin
    showmessage(IntTostr(ppReport1.PreviewForm.Top));
    showmessage(IntTostr(ppReport1.PreviewForm.Left));
    showmessage(IntTostr(ppReport1.PreviewForm.Width));
    showmessage(IntTostr(ppReport1.PreviewForm.Height));
    end;


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited August 2001
    Thanky you, the standard preview works fine with the changes in the two
    events.

    I have hundreds of reports to change. Wouldn't it be possible to override
    the Previewcreate and Previewclose events of the report just after loadding
    them from a file ?

    All Previewcreate events should call the same Mypreviecreate procedure and
    the Previewclose events should call the MyPreviewclose procedure.

    procedure LoadRTM(PP: TppReport; FN:String);
    Begin
    pp.Template.Filename:=TemplatesPath + FN;
    pp.Template.LoadFromFile;
    pp.Reset;
    .....
    Albert Kessler




  • edited August 2001
    After you load a template into a report, you can assign the event handler
    for the OnPreviewFormClose and OnPreviewFormCreate events:

    myReport.Template.LoadFromFile;
    myReport.OnPreviewFormCreate := MyPreviewCreate;
    myReport.OnPreviewFormClose := MyPreviewClose;


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited August 2001
    If I just assign
    myReport.OnPreviewFormCreate := MyPreviewCreate;
    and the define

    Procedure MyPreviewCreate;
    Begin
    ....
    end;

    then I get an error "incompatible types: pointer to method and regular
    method"

    Dont I have to override this event ? Can you help me with this ?

    Thank you, Albert Kessler



  • edited August 2001
    Albert,

    MyPreviewCreate should be method declaration in the TForm descendant that
    holds the RB components, ie.

    procedure TMyMainForm.MyPreviewCreate(Sender: TObject);

    --

    elektronik-labor Carls GmbH & Co. KG
    Stefan Paege

    Kontakt: +49 (0)5973 9497-23 Fax: +49 (0)5973 9497-16

This discussion has been closed.