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

#include <vcl.h>
#pragma hdrstop

#include "OnActiveFormChange.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: OnActiveFormChange
// Property: Forms.TScreen.ActiveForm
// Event: Forms.TScreen.OnActiveFormChange

// BeginCode
/*
This example uses two forms with a button on the first
form. When the user clicks the button, the second form
appears. As the user switches between forms, the form that
is active is colored aqua.
Note:	You must include the unit header for form 2 to the
unit file for form 1, and add the public ColorForm method
to the definition of the TForm1 class.
*/
#include "Unit2.h"

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  Form2->Show();
}

void __fastcall TForm1::ColorForm(TObject *Sender)
{
  Color = clWhite;
  Form2->Color = clWhite;
  Screen->ActiveForm->Color = clAqua;
}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  Screen->OnActiveFormChange = ColorForm;
}

void __fastcall TForm1::FormDestroy(TObject *Sender)
{
  // This stops ColorForm from being called during termination.
  Screen->OnActiveFormChange = NULL;
}
// EndCode
// EndExample: OnActiveFormChange
//---------------------------------------------------------------------------

