function OpenPageForm(PageCtrl: TcxPageControl; AClassForm: TClass; AForm: TForm; ACaption: string): THandle;
var
  I: Integer;
  bool: Boolean;
begin
  bool := False;
  with PageCtrl do begin
    for I := 0 to PageCount - 1 do begin
      if SameText(Trim(Pages[i].Caption), Trim(ACaption)) then begin
        bool := True;
        ActivePageIndex := i;
        Result := ActivePage.Tag;
      end;
    end;
  end;
  if not bool then begin
      Application.CreateForm(TComponentClass(AClassForm), AForm);
      //Application.CreateForm(TComponentClass(GetClass('Thomefor')),AForm);
    with AForm do begin
      ManualDock(PageCtrl);
      Caption := ACaption;
      Visible := True;
    end;
    with PageCtrl do begin
      ActivePageIndex := PageCount - 1;
      ActivePage.Tag := AForm.Handle;
      Result := ActivePage.Tag;
    end;
  end;
end;
 怎么样修改才能把AClassForm: TClass; AForm: TForm参数变成sting类型的
例如:function OpenPageForm(PageCtrl: TcxPageControl; AClassForm: string; AForm: string; ACaption: string): THandle;
下面该怎么样修改,刚学习delphi求助!  谢谢大牛们!

解决方案 »

  1.   

    写过类似的代码,不过在公司,没有相关的代码,我得回去给你找找我记得我是在数据库存了两个值,一个formClass 一个 formName;比如Form1  TForm1;然后再form1代码最后面的时候,需要进行注册Tform1然后每次打开Tab的时候,判断Tab是否存在,如果不存在,则创建form。但是也有点bug,就是Tab不能free,如果free了,无法在创建Form,当然可能你有更好的办法,我是每次Tab关闭的时候,吧Tab隐藏。你可以查下资料先,如果找不到的话,我晚上回去给你找找。
      

  2.   


    可以free掉,但现在我上面的函数不知道怎么修改了,求大牛帮忙修改..
      

  3.   

    AClassForm: TClass;
    ----AClassForm.ClassName  --得到类名AForm: TForm
    ----AForm.Name --得到窗体的名字
    ----AForm.ClassName --得到窗体的类名
      

  4.   

    function OpenPageForm(PageCtrl: TcxPageControl; AClassFormName: string; AForm: string; ACaption: string): THandle;
    begin
     if getClass(AClassFormName) <> nil then
    begin
    ................
    end;
    end;
    initialization
      RegisterClass(Tfrom1);
    finalization
      UnRegisterClass(Tfrom1);
    end.