LastCyborg
Programmer
I have created some dynamic buttons, but I want that every button do differents things, so my doubt is what can I do to tell every button what to do?
For example:
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
TButton *Button[10];
int i=0;
//----------------------------------------------------------__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//----------------------------------------------------------void __fastcall TForm1::Button1Click(TObject *Sender)
{
Button = new TButton (this);
Button->Caption = AnsiString("NewButton" + IntToStr(i));
Button->Top = i*35;
Button->Parent = Form1;
i++;
}
//----------------------------------------------------------void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
delete Button;
}
I want that if I pressed the "NewButton 3" make a change a color, if "NewButton4" is pressed, change the caption of another button etc.
For example:
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
TButton *Button[10];
int i=0;
//----------------------------------------------------------__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//----------------------------------------------------------void __fastcall TForm1::Button1Click(TObject *Sender)
{
Button = new TButton (this);
Button->Caption = AnsiString("NewButton" + IntToStr(i));
Button->Top = i*35;
Button->Parent = Form1;
i++;
}
//----------------------------------------------------------void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
delete Button;
}
I want that if I pressed the "NewButton 3" make a change a color, if "NewButton4" is pressed, change the caption of another button etc.