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

Using Report template question

edited April 2002 in General
I want the ability to be able to send out a different Template file, if the
users require a different report.
This works really well until i add another component that was not already in
the original report.
Then i get an error message coming up(after i close the error box the report
works fine)
Now i think this is because all the original component definitions are help
on the Form.

I seem to remember, i read a thread saying how to define your own dialog, so
this error will not come up.
I can't find this thread, so could somebody please help me out with this
please.

Many thanks
John

Comments

  • edited April 2002
    Hi John,

    register your own dialog.
    I don't show the dialog, but write the unknown property/method into a log
    file, that my human report designer knows - Ah, here's a report I should
    open and save.

    here some code from my main datamodule :


    ppUnRegisterForm(TppCustomTemplateErrorDialog);
    ppRegisterForm(TppCustomTemplateErrorDialog, TdlgTemplateErrorDialog);


    and here the code for the dialog :


    unit UdlgTemplateErrorDialog;

    interface

    uses
    Windows,
    Messages,
    SysUtils,
    Classes,
    Graphics,
    Controls,
    Forms,
    Dialogs,
    ppForms,
    ppTypes,
    ppUtils,
    StdCtrls,
    ExtCtrls;

    type
    TdlgTemplateErrorDialog = class(TppCustomTemplateErrorDialog)
    pnlMain: TPanel;
    pnlBottom: TPanel;
    memErrorMessage: TMemo;
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    private
    { Private-Deklarationen }
    protected
    function GetErrorMessage : String; override;
    procedure SetErrorMessage(pmMessage : String); override;
    public
    { Public-Deklarationen }
    end;

    var
    dlgTemplateErrorDialog: TdlgTemplateErrorDialog;

    implementation

    {$R *.DFM}

    uses
    ppReport;

    procedure TdlgTemplateErrorDialog.FormShow(Sender: TObject);
    begin
    PostMessage(Handle, WM_CLOSE, 0, 0);
    end;

    function TdlgTemplateErrorDialog.GetErrorMessage : String;
    begin
    Result := memErrorMessage.Text;
    end;

    procedure TdlgTemplateErrorDialog.SetErrorMessage(pmMessage : String);
    var
    af : TForm;
    msg : String;
    fn : String;
    ms : TMemoryStream;
    begin
    memErrorMessage.Text := pmMessage;

    // log this message
    try
    fn := ExtractFilePath(Application.ExeName) + 'event.report.log';
    ms := TMemoryStream.Create;
    try
    if FileExists(fn) then begin
    ms.LoadFromFile(fn);
    end;
    ms.Seek(0, soFromEnd);

    msg := DateTimeToStr(Now) + ' : ' + pmMessage + #13#10;

    af := Screen.ActiveForm;

    // proprietary code here
    [...].

    msg := msg + '----------------------------------' + #13#10;

    ms.Write(msg[1], Length(msg));

    ms.SaveToFile(fn);
    finally
    ms.Free;
    end;
    except
    on E : Exception do begin
    end;
    end; // try/except
    end;

    procedure TdlgTemplateErrorDialog.FormClose(Sender: TObject;
    var Action: TCloseAction);
    begin
    ModalResult := mrAll;
    end;

    procedure TdlgTemplateErrorDialog.FormCreate(Sender: TObject);
    begin
    // no flicker, this form is a dummy and really shown!
    Left := Screen.Width;
    end;

    end.


    regards,
    Chris Ueberall;

This discussion has been closed.