使用toolsApi遇到的问题:Error Creating Form:Interface not supported!
各位cnpack的专家,您好:
一个bpk项目,安装编译生成的bpl后在object repository出现自定义窗体模板,可通过该模板创建自己的Form.
该模板部分代码如下:
namespace Adfexperts
{
void __fastcall PACKAGE Register()
{
RegisterLibraryExpert(new TBaseADFExpert);
RegisterCustomModule(__classid(TForm_ADFBaseForm), __classid(TBaseCustomModule));
}
}
//-------------------------------------------------------------------------
void HandleException(void)
{
ToolServices->RaiseException(ReleaseException());
}
//---------------------------------------------------------------------------
TExpertStyle __stdcall TBaseADFExpert::GetStyle()
{
return esForm;
}
AnsiString __stdcall TBaseADFExpert::GetName()
{
return "A";
}
AnsiString __stdcall TBaseADFExpert::GetAuthor()
{
return "article";
}
AnsiString __stdcall TBaseADFExpert::GetComment()
{
return "AD";
}
AnsiString __stdcall TBaseADFExpert::GetPage()
{
return "";
}
HICON __stdcall TBaseADFExpert::GetGlyph()
{
return LoadIcon( HInstance,"AAA");
}
TExpertState __stdcall TBaseADFExpert::GetState()
{
return TExpertState()<<esEnabled;
}
AnsiString __stdcall TBaseADFExpert::GetIDString()
{
return "aaa";
}
AnsiString __stdcall TBaseADFExpert::GetMenuText()
{
return "aaa";
}
void __stdcall TBaseADFExpert::Execute()
{
TForm_SelectFormType* SelectForm = new TForm_SelectFormType(Application);
TModalResult aResult = SelectForm->ShowModal();
if (aResult != mrOk)
{
delete SelectForm;
return;
}
AnsiString FormTypeName;
switch (SelectForm->RadioGroup1->ItemIndex)
{
case 0: FormTypeName = "Form_ADFBaseForm";
break;
}
AnsiString HeaderFileName;
switch (SelectForm->RadioGroup1->ItemIndex)
{
case 0: HeaderFileName = "ADFBaseForm.h";
break;
}
delete SelectForm;
AnsiString ModuleName, FormName, FileName;
TIModuleInterface* ModIntf;
ToolServices->GetNewModuleAndClassName(
FormTypeName, ModuleName, FormName, FileName);
ModIntf = ToolServices->CreateModuleEx(FileName, FormName,
FormTypeName, "", NULL, NULL,
TCreateModuleFlags()<< cmShowSource<< cmShowForm<<cmNewForm<< cmAddToProject << cmUnNamed);
TIEditorInterface* aEditor = ModIntf->GetAuxEditorInterface();
TIEditWriter* aWriter = aEditor->CreateWriter();
aWriter->CopyTo(286);
aWriter->Insert(("\r\n#include \""+HeaderFileName+"\"\r\n").c_str());
aWriter->Release();
aEditor->Release();
ModIntf->Release();
}
在BCB6编译通过后,运行报Error Creating Form:Interface not supported。
我怀疑问题在:RegisterCustomModule函数那里,或者是CreateModuleEx函数那里。
我就这个问题搞了两三天了,依然搞不定.请高手帮我看看,找找问题所在,感激不尽!
|