对vcl库底层机制一些不明白的地方4
热门软件下载:
刚刚写了一个可视控件,但在发布它的一些属性时遇到了点问题。
这个属性的值我希望以下拉列表提供。
下面是我的代码。请各位高手指点。
.h
class tfieldnamepropertyeditor: public tpropertyeditor
{
public:
__fastcall tfieldnamepropertyeditor(const_di_idesigner adesigner, int apropcount);
virtual __fastcall ~tfieldnamepropertyeditor(void);
tpropertyattributes __fastcall getattributes(void);
void __fastcall getvalues(classes::tgetstrproc proc);
};
//---------------------------------------------------------------------------
ttypeinfo* ansistringtypeinfo(void); //定义类型信息
.cpp
namespace newcomponent
{
void __fastcall package register()
{
registerpropertyeditor(ansistringtypeinfo(), __classid(tnewcomponent), "parentidfield", __classid(tfieldnamepropertyeditor));//注册属性
registerpropertyeditor(ansistringtypeinfo(), __classid(tnewcomponent), "idfield", __classid(tfieldnamepropertyeditor));//注册属性
registerpropertyeditor(ansistringtypeinfo(), __classid(tnewcomponent), "displayfield", __classid(tfieldnamepropertyeditor));//注册属性
tcomponentclass classes[1] = {__classid(tnewcomponent)};
registercomponents("samples", classes, 0);
}
}
//------------------------------------------------------------------
__fastcall tfieldnamepropertyeditor::tfieldnamepropertyeditor(const_di_idesigner adesigner, int apropcount)
:tpropertyeditor(adesigner,apropcount)
{
}
//---------------------------------------------------------------------------
virtual __fastcall tfieldnamepropertyeditor::~tfieldnamepropertyeditor()
{
}
//---------------------------------------------------------------------------
tpropertyattributes __fastcall tfieldnamepropertyeditor::getattributes(void)
{
return tpropertyattributes() << pavaluelist;
}
//--------------------------------------------------------------------------
void __fastcall tfieldnamepropertyeditor::getvalues(classes::tgetstrproc proc)
{
tnewcomponent* n;
n = (tnewcomponent*)getcomponent(0);
for (int i = 0; i < n->items->count;i++)
{
proc(n->items->strings[i]);
}
}
//---------------------------------------------------------------------------
ttypeinfo* ansistringtypeinfo(void) //定义类型信息
{
ttypeinfo* typeinfo = new ttypeinfo;
typeinfo->name = "ansistring";
typeinfo->kind = tklstring;
return typeinfo;
}
//---------------------------------------------------------------------------
推荐阅读
学习
.
相关评论