好像没有必要发送消息呀!我刚刚试过了,代码如下:
主窗体是Form1,第一子窗体是Form2,第二子窗体是Form3,将Form2和Form3都设为不能自动建立的窗体
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2 := TForm2.Create(Application);
Form2.Show;
end;
end.
//--------------------------------------------------------------------------
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit3;
{$R *.DFM}
procedure TForm2.Button1Click(Sender: TObject);
begin
Form3 := TForm3.Create(Application);
Form3.Show;
Form2.Release;
end;
end.
//-----------------------------------------------------------------
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm3 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm3.Button1Click(Sender: TObject);
begin
Form2 := TForm2.Create(Application);
Form2.Show;
Form3.Release;
end;
end.