#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
bool __fastcall TForm1::Show(TComponent* cmp,const AnsiString &str)
{
TButton *btn = dynamic_cast<TButton*>(cmp);
if(btn)
{
btn->Caption = str;
return true;
}
TMemo *memo = dynamic_cast<TMemo*>(cmp);
if(memo)
{
memo->Text = str;
return true;
}
return false;
}
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
const unsigned N = 3;
AnsiString cmpName[N] = {"Button1","Button2","Memo1"};
AnsiString cmpCH[N] = {"按鈕一","按鈕二","表一"};
for(int i = 0 ; i < ComponentCount ; ++i)
{
for(unsigned j = 0 ; j < N ; ++j)
{
if(Components[i]->Name == cmpName[j])
{
Show(Components[i],cmpCH[j]);
}
}
}
}
I2luY2x1ZGUgPHZjbC5oPgojcHJhZ21hIGhkcnN0b3AKCiNpbmNsdWRlICJVbml0MS5oIgojcHJhZ21hIHBhY2thZ2Uoc21hcnRfaW5pdCkKI3ByYWdtYSByZXNvdXJjZSAiKi5kZm0iClRGb3JtMSAqRm9ybTE7CmJvb2wgX19mYXN0Y2FsbCBURm9ybTE6OlNob3coVENvbXBvbmVudCogY21wLGNvbnN0IEFuc2lTdHJpbmcgJnN0cikKewogICAgVEJ1dHRvbiAqYnRuID0gZHluYW1pY19jYXN0PFRCdXR0b24qPihjbXApOwogICAgaWYoYnRuKQogICAgewogICAgICAgIGJ0bi0+Q2FwdGlvbiA9IHN0cjsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KCiAgICBUTWVtbyAqbWVtbyA9IGR5bmFtaWNfY2FzdDxUTWVtbyo+KGNtcCk7CiAgICBpZihtZW1vKQogICAgewogICAgICAgIG1lbW8tPlRleHQgPSBzdHI7CiAgICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICByZXR1cm4gZmFsc2U7Cn0KX19mYXN0Y2FsbCBURm9ybTE6OlRGb3JtMShUQ29tcG9uZW50KiBPd25lcikKICAgIDogVEZvcm0oT3duZXIpCnsKICAgIGNvbnN0IHVuc2lnbmVkIE4gPSAzOwogICAgQW5zaVN0cmluZyBjbXBOYW1lW05dID0geyJCdXR0b24xIiwiQnV0dG9uMiIsIk1lbW8xIn07CiAgICBBbnNpU3RyaW5nIGNtcENIW05dID0geyLmjInpiJXkuIAiLCLmjInpiJXkuowiLCLooajkuIAifTsKICAgIGZvcihpbnQgaSA9IDAgOyBpIDwgQ29tcG9uZW50Q291bnQgOyArK2kpCiAgICB7CiAgICAgICAgZm9yKHVuc2lnbmVkIGogPSAwIDsgaiA8IE4gOyArK2opCiAgICAgICAgewogICAgICAgICAgICBpZihDb21wb25lbnRzW2ldLT5OYW1lID09IGNtcE5hbWVbal0pCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIFNob3coQ29tcG9uZW50c1tpXSxjbXBDSFtqXSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9Cn0K