Title: Message
The following example came up recently.
 
TForm1 = class(TForm)
public
  constructor Create(POwner: TComponent); override;
  class procedure ShowMe;
end;
 
constructor TForm1.Create(POwner: TComponent)
begin
  ShowMessage('TForm1.Create 1');
  inherited Create(POwner);
  ShowMessage('TForm1.Create 2');
end;
 
class procedure TForm1.ShowMe
var
    LForm: TForm1;
begin
  LForm1 := Self.Create(nil);
  try
    LForm1.ShowModal;
  finally
    LForm1.Free
  end;
end;
 
TForm2 = class(TForm)
public
  constructor Create(POwner: TComponent); override;
end;
 
constructor TForm2.Create(POwner: TComponent)
begin
  ShowMessage('TForm2.Create 1');
  inherited Create(POwner);
  ShowMessage('TForm2.Create 2');
end;
 
TForm3 = class(TForm)
public
  constructor Create(POwner: TComponent; PWhoCares: Boolean); reintroduce;
end;
 
constructor TForm3.Create(POwner: TComponent; PWhoCares: Boolean)
begin
  ShowMessage('TForm3.Create 1');
  inherited Create(POwner);
  ShowMessage('TForm3.Create 2');
end;
 
TForm4 = class(TForm3)
public
  constructor Create(POwner: TComponent); reintroduce; // Can't be inherited because create is reintroduced in TForm3.
end;
 
constructor TForm4.Create(POwner: TComponent)
begin
  ShowMessage('TForm4.Create 1');
  inherited Create(POwner);
  ShowMessage('TForm4.Create 2');
end;
 
Calling TForm2.ShowMe works perfectly showing all of the correct messages.
 
Calling TForm4.ShowMe does not and only shows the messages for TForm1.
 
The flag reintroduce must create a new heirarchy in the virtual method table...
 
Interesting huh.
 
Stacey Verner             Ph:   +64-9-4154790
Software Developer        Fax:  +64-9-4154791
                          DDI:  +64-9-4154797
CJN Technologies Ltd.     Email:
[EMAIL PROTECTED]
PO Box 302-278, North Harbour, Auckland 1330, New Zealand
12 Piermark Drive, North Harbour, Auckland, New Zealand
Visit our website at
http://www.cjntech.co.nz/
 
_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to