测试单元:
Unit Unit2;InterfaceUses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;Type
TForm2 = Class(TForm)
Procedure FormCreate(Sender: TObject);
Private
{ Private declarations }
Public
Constructor CreateText(AOwner: TComponent; TestNum: integer);
{ Public declarations }
End;Var
Form2: TForm2;Implementation{$R *.dfm}{ TForm2 }Constructor TForm2.UserCreateBySize(AOwner: TComponent; TestNum: integer);
Begin
Tag:=TestNum;
Inherited Create(AOwner);
self.Caption := '2222222222222';
End;Procedure TForm2.FormCreate(Sender: TObject);
Begin
self.Caption := '1111111111111';
End;End./////////////////////////////////
在主窗口的某一Button事件中调用:
Form2 := TForm2.UserCreateBySize(application, 1);
Form2.Show;
按道理此时Form2的窗口标题应该显示为'22222222222',而在我的系统中却显示为'11111111111111',跟踪了一下发现在构造函数中Inherited Create(AOwner);执行完了后就执行self.caption='22222222222',然后才执行OnCreate事件。
我的系统是Vista+Delphi7(Vista+Delphi2007也是同样问题)。但此问题在XP+Delphi7却不存在,为什么?
Unit Unit2;InterfaceUses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;Type
TForm2 = Class(TForm)
Procedure FormCreate(Sender: TObject);
Private
{ Private declarations }
Public
Constructor CreateText(AOwner: TComponent; TestNum: integer);
{ Public declarations }
End;Var
Form2: TForm2;Implementation{$R *.dfm}{ TForm2 }Constructor TForm2.UserCreateBySize(AOwner: TComponent; TestNum: integer);
Begin
Tag:=TestNum;
Inherited Create(AOwner);
self.Caption := '2222222222222';
End;Procedure TForm2.FormCreate(Sender: TObject);
Begin
self.Caption := '1111111111111';
End;End./////////////////////////////////
在主窗口的某一Button事件中调用:
Form2 := TForm2.UserCreateBySize(application, 1);
Form2.Show;
按道理此时Form2的窗口标题应该显示为'22222222222',而在我的系统中却显示为'11111111111111',跟踪了一下发现在构造函数中Inherited Create(AOwner);执行完了后就执行self.caption='22222222222',然后才执行OnCreate事件。
我的系统是Vista+Delphi7(Vista+Delphi2007也是同样问题)。但此问题在XP+Delphi7却不存在,为什么?
个人估计是因为vista更改了api的调用什么的,可能调用方式发生了改变?