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

How can I intercept a moment when Designer will save a report

edited August 2003 in End User
How can I intercept a moment when Designer will and did save a report
template
I did try to use OnClose and OnCloseQuery but it is to late
I can use only TppDesigner, and TppReport

Purpose:

- request a new name or change existing when report is about to be saved -
it should be my form and complex enough
- to be notified when report is saved to template file to copy it in special
location

Sorry, this question was discussed here for 2 years but looks like there
were some changes which affected a solutions provided
If there was an answer for v7, could someone point to a particular thread

--
Serge Dosyukov
Borland Delphi 6 product certified
MCP
"Programming is not a job; it is a style of life."

Comments

  • edited August 2003
    Hi Serge,

    There is the OnCustomSaveDoc event on the designer component which provides
    you the ability to code your own saving logic. That might be more than what
    you want to do in this case since you want to allow the report to save
    normally, just change the name and save a copy.

    What will be more useful to you are the public events on the Report.Template
    called OnSaveStart and OnSaveEnd. Use these events to be notified when a
    template is about to be saved. See the help file on these two event for
    their special purposes. If you use the OnSaveEnd you can access the stream
    and then create a new fiel stream and save a copy of the stream somewhere
    for your report copy you mentioned.


    Cheers,

    Jim Bennett
    Digital Metaphors

    ...
    ..
    .
    private
    { Private declarations }
    procedure ehTemplateSaveStart(Sender: TObject);

    public
    { Public declarations }
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.DFM}

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    ppReport1.Template.OnSaveStart := ehTemplateSaveStart;
    ppDesigner1.ShowModal;
    end;

    procedure TForm1.ehTemplateSaveStart(Sender: TObject);
    var
    lsNewFileName: String;
    begin

    lsNewFileName := ExtractFilePath(ParamStr(0))+ '123.rtm';

    ppReport1.Template.FileName := lsNewFileName;

    end;
This discussion has been closed.