窗体打开与关闭的问题(72分)

  • 主题发起人 kidman520
  • 开始时间
建立一个全局变量:Myhandle:HWND
每次打开窗体时在CREATE事件中写入(主窗口和登录窗口除外)
首先SendMessage(MyHandle,WM_Close,0,0)
然后把该窗体的句柄写入MyHandle.
具体细节你自己控制
 
准备给分吧!!
function TFormMain.FreeChildForm: Boolean;
begin
if Assigned(FForm1) then
begin
FForm1.Free;
FForm1:= nil;
end;
if Assigned(FForm2) then
begin
FForm2.Free;
FForm2:= nil;
end;
end;

button事件:
if not Assigned(FForm1) then
begin
if not FreeChildForm then
exit;
FForm1:= TForm1.Create(Self);
FForm1.Show;
end;

 
用一个循环好了。
for i:=1 to componentcountdo
if mainform(findcomponent('form'+inttostr(i)))<>nil then
mainform(findcomponent('form'+inttostr(i))).close;
 
多人接受答案了。
 

Similar threads

回复
0
查看
575
不得闲
S
回复
0
查看
622
SUNSTONE的Delphi笔记
S
S
回复
0
查看
703
SUNSTONE的Delphi笔记
S
顶部