#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]);
            }
        }
    }
}
