Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:2k
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- BnCount=0;
- }
- //---------------------------------------------------------------------------
- __fastcall TForm1::~TForm1()
- {
- DeleteAllBn();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::DeleteAllBn(void)
- {
- int ii;
- for(ii=0;ii<BnCount;ii++)
- {
- delete Bn[ii];
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- int ii,yy,ww;
- ww=12;yy=45;
- DeleteAllBn();
- for(ii=0;ii<10;ii++)
- {
- Bn[ii]=new TButton(this);
- Bn[ii]->Parent=this;
- Bn[ii]->OnClick=BtnClick;
- Bn[ii]->Caption=IntToStr(ii);
- if((ww+Bn[ii]->Width+5)>Width)
- {
- yy=yy+Bn[ii]->Height+5;
- ww=12;
- }
- Bn[ii]->Left=ww;
- Bn[ii]->Top=yy;
- ww=ww+Bn[ii]->Width+5;
- }
- BnCount=10;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- int ii,yy,ww;
- ww=12;yy=45;
- DeleteAllBn();
- for(ii=0;ii<26;ii++)
- {
- Bn[ii]=new TButton(this);
- Bn[ii]->Parent=this;
- Bn[ii]->OnClick=BtnClick;
- Bn[ii]->Caption=Char('A'+ii);
- if((ww+Bn[ii]->Width+5)>Width)
- {
- yy=yy+Bn[ii]->Height+5;
- ww=12;
- }
- Bn[ii]->Left=ww;
- Bn[ii]->Top=yy;
- ww=ww+Bn[ii]->Width+5;
- }
- BnCount=26;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::BtnClick(TObject *Sender)
- {
- TButton *cn;
- cn=(TButton *)Sender;
- Edit1->Text=cn->Caption;
- }
- //---------------------------------------------------------------------------