分享

通用窗口创建代码

 独孤求财 2012-03-20

通用窗口创建代码

时间:2011-5-26来源:yang 作者: peng点击: 19次

//==============================================================================
// if mark=0 then Tform.show else Tform.showmodal
//==============================================================================

procedure OpenChildForm(FormClass:TFormClass;Mark:Integer=0);
var
  I: Integer;
  Child: TForm;
begin
  if Mark=0 then    
  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_SHOWMAXIMIZED)
        else
          ShowWindow(Child.handle,SW_SHOWNA);
        if (not Child.Visible) then Child.Visible := True;
          Child.BringToFront;
          Child.Setfocus;
          Exit;
      end;
    Child := TForm(FormClass.NewInstance);
    Child.Create(Application);
  end else begin
    Child:=TForm(FormClass.NewInstance);
    Child.Create(nil).ShowModal;
    Child.Free;
  end;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

//==============================================================================
// if mark=0 then Tform.show else Tform.showmodal
//==============================================================================

procedure OpenChildForm(FormClass:TFormClass;var Form:TForm;Mark:Integer=0);
begin
  if Mark=0 then
  begin
    if not Assigned(form) then Application.CreateForm(FormClass,Form);
    if Form.WindowState=wsminimized then Form.WindowState:=wsMaximized;
  end else begin
    form:=FormClass.Create(nil);
    Form.ShowModal;
    Form.Free;
  end;
end;

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多