⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.cpp

📁 有视频
💻 CPP
字号:
//---------------------------------------------------------------------------
#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;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -