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

来源:互联网 发布:smali文件转java 编辑:程序博客网 时间:2024/05/22 23:48

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 可轻松实现界面的多语言支持;


引用块内容

========================================================================

阅读全文
0 0