{两个单元文件,FORM1启动里加载,FORM2不加载,由程序动态加载,怎么判断FORM2已经启动过了呢?
求的情况是。
FORM1按BUTTON1模态加载了FORM2,按FORM2的BUTTON1,模态加载了FOM1,
此时怎么知道FORM2已经被加载过了呢。FORM1里的BUTTON2是我的代码,但好象求不出来哟,都是NO
}
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation
uses unit2;
{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var lform:Tform;
begin
lform:=tform2.Create(self);
lform.ShowModal ;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
if Assigned(form2) then
ShowMessage('ok')
else
ShowMessage('no');
end;end.
unit Unit2;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
ko:Integer;
class function getko():Integer;
{ Private declarations }
public { Public declarations }
end;var
Form2: TForm2;implementation
uses unit1;
{$R *.dfm}procedure TForm2.Button1Click(Sender: TObject);
var lform:Tform;
begin
lform:=tform1.Create(self);
lform.ShowModal;;
end;class function TForm2.getko: Integer;
beginend;end.
求的情况是。
FORM1按BUTTON1模态加载了FORM2,按FORM2的BUTTON1,模态加载了FOM1,
此时怎么知道FORM2已经被加载过了呢。FORM1里的BUTTON2是我的代码,但好象求不出来哟,都是NO
}
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation
uses unit2;
{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var lform:Tform;
begin
lform:=tform2.Create(self);
lform.ShowModal ;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
if Assigned(form2) then
ShowMessage('ok')
else
ShowMessage('no');
end;end.
unit Unit2;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
ko:Integer;
class function getko():Integer;
{ Private declarations }
public { Public declarations }
end;var
Form2: TForm2;implementation
uses unit1;
{$R *.dfm}procedure TForm2.Button1Click(Sender: TObject);
var lform:Tform;
begin
lform:=tform1.Create(self);
lform.ShowModal;;
end;class function TForm2.getko: Integer;
beginend;end.
解决方案 »
- 把panel的DragKind属性设为dkDock,在OnMouseDown事件中写代码:panel.BeginDrag(False);
- 在Delphi怎麼把ole裡面的數據嵌入word裡面對映的字段?謝謝
- 关于考勤的旷工问题
- 过程调用问题.初学DELPHI.前辈们帮忙一下!`
- 在XP下安装的Delphi7,不能运行编译请各位高手指教
- 怎样在EDIT的KeyPress事件中调用Edit1Exit事件????
- 为什么会出现说无效的SQL语句
- DBGrid如何控制单独的单元格>>>???
- 急急急!!!!一个十分奇怪的问题。
- ???????快帮帮忙吧,有关打印的问题,只剩这么多分了???????
- 求助
- 关于小数的四舍五入问题!!!
var lform:Tform;
begin
lform:=tform2.Create(self);
lform.ShowModal ;
FreeAndNil(lform); //
end;其它代碼不用!!!
begin
form2:=tform2.Create(self);
form2.ShowModal ;
FreeAndNil(form2); //
end;
var lform:Tform;
begin
lform:=formclass.Create(self);
result:=lform;
//FREEANDNIL --肯定不行,窗体都加不上,报错。
end;
procedure TfrmMain.Button1Click(Sender: TObject);
begin
createform(TFROM1).ShowModal;
end;
我的窗体都是这样加载的,不能用FREEANDNIL,(或许不知道怎么做),因为这是言主的,有几十个窗体之多。
begin
form2:=tform2.Create(self);
form2.ShowModal ;
FreeAndNil(form2); //
end;
var lform:Tform;
begin
lform:=formclass.Create(self);
result:=lform;
//FREEANDNIL --肯定不行,窗体都加不上,报错。
end;
procedure TfrmMain.Button1Click(Sender: TObject);
begin
createform(TFROM1).ShowModal;
end;
我的窗体都是这样加载的,不能用FREEANDNIL,(或许不知道怎么做),因为这是言主的,有几十个窗体之多。帮忙看一下我的代码应该怎么改哟
begin
if not assigned(Form2) then
begin
Form2:=Tform2.Create(nil);
form2.ShowModal;
Form2.Free; //添加这两行代码..
form2:=nil; //
End;
end;