TMyForm = class(TForm)
...
End;我想要一个过程Show(TMyForm);
我如何写这个过程呢!

解决方案 »

  1.   

    procedure ShowAForm(aForm:TMyForm)
    begin
      TMyForm.show;
    end;
      

  2.   

    我是用的MDI。
    用这个过程,是为了判断主窗体的所有子窗体中是否有这个类的实例,有的话就显示,没的话就创建并且显示。
      

  3.   

    //我写错了,sorry
    procedure ShowAForm(aForm:TMyForm)
    begin
      if not Assigned(aForm) then aForm:=TMyForm.Create(nil);
      aForm.show;
    end;
      

  4.   

    出现了"Incompatible types: 'TObject'and'Class reference'"的错误。
      

  5.   

    have a tryTFormClass = class of TForm;procedure Show(aFormClass :TFormClass);
    var
      Instance :TComponent;
    begin
      Instance := TForm(aFormClass.NewInstance);
      try
        Instance.Show();
      except
        //
      end;  
    end;
      

  6.   

    procedure TfrmMain.ShowForm(AFormClass: TForm);
    begin
      AFormClass.Create(Application).Show;
    end;调用的时候是
      ShowForm(TfrmMain);这样就会出现上面的错误了!
      

  7.   

    I think you do not need a class parameter, just need an instance parameter, this is like the code of jinjazz(近身剪(N-P攻略)) 
    procedure Show(aForm :TMyForm);
    begin
      if not Assigned(aForm) then 
        aForm:=TMyForm.Create(Self);
      aForm.Show;
    end;
      

  8.   

    is TfrmMain class or instance?
    if is class, you should define a class type like TFormClass = class of TForm;
    TfrmMain.ShowForm(AFormClass: TForm);  //AFormClass is instance of TForm not class, you should understand this
      

  9.   

    I think you should be familiar with the procedure Application.CreateForm(TForm, Form1)
    please refer to Application.CreateForm(InstanceClass: TComponentClass; var Reference)
    the first parameter is class, the second parameter is instance