CnPack Forum


 
Subject: 使用toolsApi遇到的问题:Error Creating Form:Interface not supported!
downsource
新警察
Rank: 1



UID 126
Digest Posts 0
Credits 2
Posts 2
点点分 2
Reading Access 10
Registered 2003-7-31
Status Offline
Post at 2003-7-31 22:09  Profile | Site | Blog | P.M. 
使用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函数那里。
   我就这个问题搞了两三天了,依然搞不定.请高手帮我看看,找找问题所在,感激不尽!
Top
downsource
新警察
Rank: 1



UID 126
Digest Posts 0
Credits 2
Posts 2
点点分 2
Reading Access 10
Registered 2003-7-31
Status Offline
Post at 2003-8-1 12:29  Profile | Site | Blog | P.M. 
呵呵,搞定了,是RegisterCustomModule函数那里出了问题。

RegisterCustomModule(__classid(TForm_ADFBaseForm), __classid(TBaseCustomModule));

应该写成:
RegisterCustomModule(__classid(TForm_ADFBaseForm), __classid(TCustomModule));


BCB6中TCustomModule是在的designeditors.hpp文件中定义的。
Top
zjy
管理员
Rank: 9Rank: 9Rank: 9



UID 2
Digest Posts 6
Credits 2385
Posts 1543
点点分 2385
Reading Access 102
Registered 2002-12-16
Location China
Status Offline
Post at 2003-8-1 13:25  Profile | Site | Blog | P.M. 
呵呵,不错啊:)
如果有兴趣,多多交流哩!
CnPack 管理员信箱:cnpack@163.com




Zhou JingYu
CnPack Administrator
http://www.cnpack.org/
Top
 




All times are GMT++8, the time now is 2024-4-21 04:02

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.006820 second(s), 8 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP