form constructor never called

From: Jimmy Rasmussen (jimmyr_at_get2net.dk)
Date: 04/28/04


Date: Wed, 28 Apr 2004 19:50:35 +0200

I wrote this code:

type TTestForm = class(TForm)
  public
  constructor Create(AOwner: TComponent);
  end;

constructor TTestForm.Create(AOwner: TComponent);
begin
Showmessage('Yo the test constructor here'); //never called !
end;

I created a new form at design time.
I exchanged this line TForm2 = class(TForm)
with this one TForm2 = class(TTestForm)

Now, since delphi creates the forms automatically when the application
starts up (by calling the forms constructors I presume ...) I don't
understand why the TTestForm constructor is not called, however I suspect it
has something to do with the way the delphi streaming system operates. Of
course creating the form explicitly in the code will solve the problem, but
still, I'd like to whats going on here.

regards
Jimmy



Relevant Pages

  • Re: OnCreate and OnDestroy of non-form object
    ... if you look in the source for TObject and TComponent ... static function ... ... constructor Create; virtual; ... but your descendant constructor allocates the memory. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Non-visual compnent in a TThread descendent
    ... actually used this variable, and the code in the Constructor for TComponent, ... and nil should work just fine. ... >> TComponent descendent, ...
    (borland.public.delphi.non-technical)
  • Re: WMMOUSELEAVE
    ... constructor TFormComponents.Test.Create(AOwner: TComponent); ... Panel.WindowProc:= PanelWndProc; ... FOldPanelWndProc:= Panel.WindowProc; ...
    (comp.lang.pascal.delphi.misc)
  • Re: Re[2]: D2006 Tool Palette So Inferior
    ... Very strange. ... TComponent in constructor Create; ... the hyperlinks should go, eg in the example, should the word ...
    (borland.public.delphi.non-technical)