H
hwave
Unregistered / Unconfirmed
GUEST, unregistred user!
以下LISTxx(1)过程在第一次调用时可以显示列表一,第二次调
用时就不能显示出来,原因是在第二次调用时List1Form变量不
为空,我原以为在(★★★)ListForm的Destroy中把ListForm置空了,
List1Form 、List2Form 、List3Form.......变量都会跟着置空,
实际不然,有没有办法在 ListU 单元Form析构时同时把这些变量置空
var
List1Form: TListForm; //列表1
List2Form: TListForm; //列表2
........................
.........................
procedure TMainForm.LISTxx(X: Byte); //列表显示过程
begin
if x = 1 then
begin
if not Assigned(List1Form) then
begin
List1Form := TListForm.Create(self);
List1Form.Caption := '列表一';
................
List1Form.show;
end
else if x = 2 then
begin
if not Assigned(List2Form) then
begin
List2Form := TListForm.Create(self);
List2Form.Caption := '列表二';
................
List2Form.show;
end;
end;
end;
=========================================================
unit ListU;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, ComCtrls;
type
TLISTFORM = class(TForm)
............
............
............
procedure TLISTFORM.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree; //释放Form实例
end;
procedure TLISTFORM.anCloseClick(Sender: TObject);
begin
CLOSE;
end;
procedure TLISTFORM.FormDestroy(Sender: TObject);
begin
ListForm:=nil; //★★★
end;
用时就不能显示出来,原因是在第二次调用时List1Form变量不
为空,我原以为在(★★★)ListForm的Destroy中把ListForm置空了,
List1Form 、List2Form 、List3Form.......变量都会跟着置空,
实际不然,有没有办法在 ListU 单元Form析构时同时把这些变量置空
var
List1Form: TListForm; //列表1
List2Form: TListForm; //列表2
........................
.........................
procedure TMainForm.LISTxx(X: Byte); //列表显示过程
begin
if x = 1 then
begin
if not Assigned(List1Form) then
begin
List1Form := TListForm.Create(self);
List1Form.Caption := '列表一';
................
List1Form.show;
end
else if x = 2 then
begin
if not Assigned(List2Form) then
begin
List2Form := TListForm.Create(self);
List2Form.Caption := '列表二';
................
List2Form.show;
end;
end;
end;
=========================================================
unit ListU;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, ComCtrls;
type
TLISTFORM = class(TForm)
............
............
............
procedure TLISTFORM.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree; //释放Form实例
end;
procedure TLISTFORM.anCloseClick(Sender: TObject);
begin
CLOSE;
end;
procedure TLISTFORM.FormDestroy(Sender: TObject);
begin
ListForm:=nil; //★★★
end;