//--------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "TFormActionExample.h"
//--------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
}
//--------------------------------------------------------------------

// BeginExample: TFormAction
// Property: Controls.TControl.Action
// BeginCode
/*
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 some user-defined procedure, which randomly changes
the color of the form.
*/
void __fastcall TForm1::ChangeColor(TObject *Sender)
{
  // randomly change the color of the form
  Color = Random(0xFFFF);
}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  // allocate memory for the Action property
  Action = new TBasicAction(this);

  // set the OnExecute event handler
  Action->OnExecute = ChangeColor;

  // initialize the random number generator
  Randomize();
}
// EndCode
// EndExample: TFormAction

//--------------------------------------------------------------------

