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

#include <vcl.h>
#pragma hdrstop

#include "TControlAlign.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: TControlAlign
// Property: Controls.TControl.Align
// Method: ComCtrls.TProgressBar.Create

// BeginCode
/*
Dynamically create a TProgressBar control and align it to
the bottom of the form.
*/

#include <ComCtrls.hpp>
#include <Controls.hpp>

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TProgressBar *ProgressBar = new TProgressBar(this);  // The owner will clean this up.
  ProgressBar->Parent = this;
  ProgressBar->Align = alBottom;
  TButton *Button1 = new TButton(this);  // The owner will clean this up.
  Button1->Parent = this;
}
// EndCode
// EndExample: TControlAlign

void __fastcall TForm1::FormDestroy(TObject *Sender)
{
  int I;
  TComponent *Temp; // someone might have clicked the button twice
  for (I = ComponentCount - 1; I > 0; I--)
  {
	Temp = Components[I];
	if (dynamic_cast<TProgressBar *>(Temp) != NULL)
	{
//	  AnsiString Msg = "Component name = " + Temp->Name;
//	  MessageDlg(Msg, mtCustom, mbOKCancel, 0);
	  delete Temp;
	}
}
}
//---------------------------------------------------------------------------

