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

#include <vcl.h>
#pragma hdrstop

#include "CropForms.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: CropForms
// Property: Forms.TScreen.Height
// Property: Forms.TScreen.Width
// Variable: Forms.Screen

// BeginCode
/*
The following code determines the height of all forms on the
screen and resizes any that are taller than the screen height.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  for (int i = 0; i < Screen->FormCount; i++)
  {
	if (Screen->Forms[i]->Top < 0)
	{
	  Screen->Forms[i]->Height += Screen->Forms[i]->Top;
	  Screen->Forms[i]->Top = 0;
	}
	if (Screen->Forms[i]->Left < 0)
	{
	  Screen->Forms[i]->Width += Screen->Forms[i]->Left;
	  Screen->Forms[i]->Left = 0;
	}
	if (Screen->Forms[i]->Left + Screen->Forms[i]->Width > Screen->Width)
	  Screen->Forms[i]->Width = Screen->Width - Screen->Forms[i]->Left;
	if (Screen->Forms[i]->Top + Screen->Forms[i]->Height > Screen->Height)
	  Screen->Forms[i]->Height = Screen->Height - Screen->Forms[i]->Top;
  }
}
// EndCode
// EndExample: CropForms
//---------------------------------------------------------------------------
