Delphi6的ToolsAPI的问题

时间:2021-03-27 17:33:40
问题是这样的:
    1.在Delphi6下面(D5没有问题)
    2.我要用ToolsAPI的IOTAModuleServices.CreateModule创建一个自定义窗口

我首先注册一个新的Form类如TTestForm
type
  TTestForm = class(TForm);

procedure Register;
begin
  RegisterCustomFormClass(TTestForm);
end;

然后声明一个ModuleCreator类和File类
type
TTestModuleCreateor = class(TInterfacedObject, IOTACreator, 
                            IOTAModuleCreator)
private
  fAncestorName, fUnitName, fFormName: string;
public
  function GetAncestorName: string; { Result := fAncestorName }
  function GetFormName: string; { Result := fFormName }
   ...
  procedure SetParams(aAncestor, aUnit, aForm: string);
  {
    fAncestorName := aAncestor; fUnitName := aUnit; fFormName := aForm;
  }
end;

TTestSource = class(TInterfacedObject, IOTAFile)
public
  ...
end;

在Expert的Execute里面,
var
  UnitName, FormName, FileName: string;
  aCreator: TTestModuleCreator;
begin
  if not Assigned(ToolServices) then
    Exit;

  ToolServices.GetNewModuleAndClassName('TestForm', 
                                        UnitName, 
                                        FormName, 
                                        FileName);
 
  aCreator := TTestModuleCreator.Create;
  aCreator.SetParams('TestForm', UnitName, FormName);  
  (BorlandIDEServices as IOTAModuleServices).CreateModule(aCreator);
end;

在这些Expert安装后,执行,生成了代码,但是不能生成Form,Delphi的提示信息是:
'Error creating form: interface not supported'

我不知道是不是Delphi6有一些特殊的地方,在Delphi5代码是可以正常执行的,
哪位Expert指导一下,或者告诉我一些Newsgroup,或别的什么能找到相关讨论的站点,
将不胜感激!(只能给60分?怎么搞的?其他的分要来干嘛?)

3 个解决方案

#1


update

#2


update

#3


update

#1


update

#2


update

#3


update