CropForms (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following code determines the height of all forms on the screen and resizes any that are taller than the screen height.

Code

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;
  }
}

Uses

Personal tools
Assistance