TFormAction (C++)
Description
This example shows that OnClick is the default event of a form. When the form is created, the OnExecute event of its Action property is initialized to a user-defined procedure, which randomly changes the color of the form.
Code
void __fastcall TForm1::ChangeColor(TObject *Sender)
{
// Randomly change the color of the form.
Color = Random(0xFFFF);
}
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
// Allocate memory for the Action property.
Action = new TBasicAction(this);
// Set the OnExecute event handler.
Action->OnExecute = ChangeColor;
// Initialize the random number generator.
Randomize();
}
Uses
- Vcl.Controls.TControl.Action ( fr | de | ja )
- Vcl.StdCtrls.TCheckBox.Action ( fr | de | ja )