S
shadowno
Unregistered / Unconfirmed
GUEST, unregistred user!
有form1 和form2两个窗口,form1中有一个button和一个checkbox,当我单击button时
,创建并打开form2,form2在打开的过程中检测form1中的checkbox的状态,如果被选中
,就关闭,并释放form2,如果checkbox没有被选中则继续!
部分代码如下::
////////////////////////////////////////
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,unit2;
type
TForm1 = class(TForm)
Button1: TButton;
CheckBox1: TCheckBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Application.CreateForm(Tform2, form2);
form2.ShowModal ;
end;
end.
////////////////////////////////////////
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm2 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.FormCreate(Sender: TObject);
begin
if form1.CheckBox1.checked then
begin
form2.Close; //关不掉?????????????
end;
end;
end.
,创建并打开form2,form2在打开的过程中检测form1中的checkbox的状态,如果被选中
,就关闭,并释放form2,如果checkbox没有被选中则继续!
部分代码如下::
////////////////////////////////////////
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,unit2;
type
TForm1 = class(TForm)
Button1: TButton;
CheckBox1: TCheckBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Application.CreateForm(Tform2, form2);
form2.ShowModal ;
end;
end.
////////////////////////////////////////
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm2 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.FormCreate(Sender: TObject);
begin
if form1.CheckBox1.checked then
begin
form2.Close; //关不掉?????????????
end;
end;
end.