您的位置:首页 > 编程语言 > C语言/C++

C++ builder 遍历所有组件的 caption 属性,轻松实现界面多语言支持

2017-10-16 14:09 357 查看
1.读所有组件的 caption 属性:

void __fastcall TForm1::Button1Click(TObject *Sender)

{

TPropInfo *info;

String tmp;

TForm   *FormTemp;
TObject *p;

Memo1->Clear();

for( int i=0;i<Application->ComponentCount;i++)
{
GetCaption ( Application->Components[i] );    }


}

void __fastcall TForm1::GetCaption ( TComponent *p )

{

int i,count;

String tmp;

TPropInfo *info;

count = p->ComponentCount;
for ( i=0; i<count; i++ )
{
GetCaption ( p->Components[i] );
info = GetPropInfo( p->Components[i],  "Caption" );
if ( info )
{
tmp  = p->Components[i]->Name + "=" + GetStrProp( p->Components[i], "Caption");
Memo1->Lines->Add( tmp );
}
}
return;


}

2.通过 SetStrProp ( FormTemp->Components[j], info, “SetStrProp”); 设置组件的属性;

3.通过读写一个 language.ini 可轻松实现界面的多语言支持;

引用块内容

========================================================================
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  遍历控件
相关文章推荐