bata 说的对
Tform1.formCreate 不是构造器 ,它只是OnCreate方法的实现.
在TForm的构造器继承自父类TCustomForm
以下来自Forms 单元
constructor TCustomForm.Create(AOwner: TComponent);
begin
GlobalNameSpace.begin
Write;
try
CreateNew(AOwner);//构造窗体;
if (ClassType <> TForm) and not (csDesigning in ComponentState) then
begin
Include(FFormState, fsCreating);
try
if not InitInheritedComponent(Self, TForm) then
raise EResNotFound.CreateFmt(SResNotFound, [ClassName]);
finally
Exclude(FFormState, fsCreating);
end;
if OldCreateOrder then
do
Create;//注意! 在这里调用了DoCreate 过程;
end;
finally
GlobalNameSpace.EndWrite;
end;
end;
procedure TCustomForm.DoCreate;
begin
if Assigned(FOnCreate) then
try
FOnCreate(Self);//调用了OnCreate事件;
except
if not HandleCreateException then
raise;
end;
if fsVisible in FFormState then
Visible := True;
end;
constructor TCustomForm.CreateNew(AOwner: TComponent;
Dummy: Integer);
begin
inherited Create(AOwner);
ControlStyle := [csAcceptsControls, csCaptureMouse, csClickEvents,
csSetCaption, csDoubleClicks];
Left := 0;
Top := 0;
Width := 320;
Height := 240;
FIcon := TIcon.Create;
FIcon.Width := GetSystemMetrics(SM_CXSMICON);
FIcon.Height := GetSystemMetrics(SM_CYSMICON);
FIcon.OnChange := IconChanged;
FCanvas := TControlCanvas.Create;
FCanvas.Control := Self;
FBorderIcons := [biSystemMenu, biMinimize, biMaximize];
FBorderStyle := bsSizeable;
FWindowState := wsNormal;
FDefaultMonitor := dmActiveForm;
FInCMParentBiDiModeChanged := False;
FPixelsPerInch := Screen.PixelsPerInch;
FPrintScale := poProportional;
FloatingDockSiteClass := TWinControlClass(ClassType);
FAlphaBlendValue := 255;
FTransparentColorValue := 0;
Visible := False;
ParentColor := False;
ParentFont := False;
Ctl3D := True;
Screen.AddForm(Self);
FSnapBuffer := 10;
end;
在上面的你会发现FormCreate不是构造器,但它能把你的代码加入到构造过程中而不需要你
去重载构造器