Subject:
使用toolsApi遇到的问题:Error Creating Form:Interface not supported!
[Print This Page]
Author:
downsource
Time:
2003-7-31 22:09
Subject:
使用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函数那里。
我就这个问题搞了两三天了,依然搞不定.请高手帮我看看,找找问题所在,感激不尽!
Author:
downsource
Time:
2003-8-1 12:29
呵呵,搞定了,是RegisterCustomModule函数那里出了问题。
RegisterCustomModule(__classid(TForm_ADFBaseForm), __classid(TBaseCustomModule));
应该写成:
RegisterCustomModule(__classid(TForm_ADFBaseForm), __classid(TCustomModule));
BCB6中TCustomModule是在的designeditors.hpp文件中定义的。
Author:
zjy
Time:
2003-8-1 13:25
呵呵,不错啊:)
如果有兴趣,多多交流哩!
CnPack 管理员信箱:
cnpack@163.com
Welcome to CnPack Forum (http://bbs.cnpack.org/)
Powered by Discuz! 5.0.0