It overrides the TComponent constructor, but shouldn't call it twice. My report descendent's constructor is only called once on my project when I trace through it. Can you provide us with an example that shows this behavior?
If you remove the loading from file, you will see that it is only created once. The second creation is used to stream in the report from the file, then it assigns the values to the current report object. If you watch the Destroy event, you will see that this gets called 2x as well: once when you load and a second time when you free the report object you destroyed.
Comments
report descendent's constructor is only called once on my project when I
trace through it. Can you provide us with an example that shows this
behavior?
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
reproduces the behavior:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ppComm, ppRelatv, ppProd, ppClass, ppReport;
type
TMyReport = class(TppReport)
private
FSomeField: Integer;
public
constructor Create(AOwner: TComponent); override;
end;
TForm1 = class(TForm)
Button1: TButton;
ppReport1: TppReport;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
FMyReport: TMyReport;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
FMyReport := TMyReport.Create(Self);
FMyReport.Template.FileName := 'Test1.rtm';
FMyReport.Template.LoadFromFile;
FMyReport.Free;
end;
{ TMyReport }
constructor TMyReport.Create(AOwner: TComponent);
begin
inherited;
FSomeField := 10;
end;
end.
--
Mike Kolter
President, Customizable Components
http://www.cust-comp.com
If you remove the loading from file, you will see that it is only created
once. The second creation is used to stream in the report from the file,
then it assigns the values to the current report object. If you watch the
Destroy event, you will see that this gets called 2x as well: once when you
load and a second time when you free the report object you destroyed.
Ed Dressel
Team DM
behavior.
Mike Kolter
President, Customizable Components
http://www.cust-comp.com