我有以下的超類:問題指針傳遞到一個構造作爲參數
unit DlgDefaultForm;
type
TDefaultFormDlg = class(TForm)
published
constructor Create(AOwner: TComponent); reintroduce; virtual;
end;
FormCreateFunc=function(AOwner: TComponent):TDefaultFormDlg;
其由一堆形式下降如下:
unit Form1
type
TForm1 = class(TDefaultFormDlg)
published
constructor Create(AOwner: TComponent); override;
end;
和創建如下:
unit MainForm;
procedure ShowForm(FormCreate:FormCreateFunc);
begin
(do some stuff)
FormCreate(ScrollBox1);
end;
當我運行
ShowForm(@TForm1.Create);
兩
發生兩件事情:
當我踏進TForm1.Create,AOwner =零,即使在ShowForm沒有。
我在下面一行得到EAbstractError:
unit Forms; (...) constructor TCustomForm.Create(AOwner: TComponent); begin (...) InitializeNewForm; //EAbstractError (...) end;
我在做什麼錯?
編輯:這當然不是我的確切代碼。
啊,我想知道如果我可以在變量中保存類的類型。我會試試這個。 – boileau 2011-06-12 11:28:27
看起來不錯。我在關閉表單時仍然遇到一些錯誤,但我沒有關係。 – boileau 2011-06-12 11:35:34