DELPHI技术

博客园 首页 新随笔 联系 订阅 管理
procedure OpenChildForm(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;

posted on 2005-11-19 09:15  DELPHI技术  阅读(434)  评论(0)    收藏  举报