为什么我写findclass(TForm1)的时候,程序老是出错,给我说“class TForm1 not found”,怎么办,现在不知道了。我在线等待……

解决方案 »

  1.   

    function TFrm_Main.Prf_RunListProc(As_FormName: string): Integer;
    var
      FcType: TFormClass;
      Frmname: string;
    begin
      try
        Frmname := 'T' + As_FormName;
        FcType := TFormClass(FindClass(Frmname));//-------这里报错
        if Assigned(OpenWindow) then
          OpenWindow.Free;
        Application.CreateForm(Fctype, OpenWindow);
        OpenWindow.Showmodal;
      except
        ShowMessage('该功能目前无法使用!');
        Result := -1;
      end;
      Result := 0;
    end;
      

  2.   

    Call FindClass to locate a class type by name.  FindClass searches the classes that the streaming system knows about.  Form classes and component classes that are referenced in a form declaration (instance variables) are automatically registered with the streaming system.  Other classes can be registered (with a call to RegisterClasses) so that the streaming system will recognize that class in a stream and know how to construct it. 
    我没看怎么懂,好像是说,只能查找到系统的类,如果想查到其它的类必须要注册!
      

  3.   

    老兄我给你试过了
    没有错误呀
    你的openwindow是一个窗体吧?
      

  4.   

    In the unit declarationing TForm1initialization
      RegisterClass(TForm1);That is ok.