胡杨林社区-NoNoToday-个人文章

OpenFrm()与ShowModel()

NoNoToday
2008-03-17 22:45   收藏:0 回复:0 点击:4425

    procedure OpenFrm(FormClass: TFormClass; var fm; AOwner: TComponent);
  var
   i: integer;
   Child: TForm;
  begin
   for i := 0 to Screen.FormCount - 1 do
   if Screen.Forms[i].ClassType = FormClass then
   begin
   Child := Screen.Forms[i];
   if Child.WindowState = wsMinimized then
   ShowWindow(Child.handle, SW_SHOWNORMAL)
   else
   ShowWindow(Child.handle, SW_SHOWNA);
   if (not Child.Visible) then Child.Visible := True;
   Child.BringToFront;
   Child.Setfocus;
   TForm(fm) := Child;
   exit;
   end;
   Child := TForm(FormClass.NewInstance);
   TForm(fm) := Child;
   Child.Create(AOwner);
  end;
  该函数:
   OpenFrm()
   try
   //不必采用showmodel();,因此没有停止运行。
   finally
   free;//直接释放;
   end;
  而try
   showmodel();//要在产生onclose事件才往下运行;
   finally
   free;
   end;
原创  林友收藏  

  
【点击回复或查看回帖】

传统或网络媒体转载请与作者联系,并注明转自【胡杨林】及作者名,否则即为侵权。

Copyright © 2008 MY510.COM 版权所有