unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls,
ExtCtrls, Buttons, Menus;
type
{ TForm1 }
TForm1 = class(TForm)
Notebook1: TNotebook;
PaintBox1: TPaintBox;
PaintBox2: TPaintBox;
Button1: TButton;
Button2: TBUtton;
Page1: TPage;
Page2: TPage;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
private
public
end;
var
Form1: TForm1;
AutoZoom: array of array of real;
FormAspect: real;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
FormAspect := Self.Width / Self.Height;
SetLength(AutoZoom, Self.ControlCount, 6);
for i := 0 to Self.ControlCount - 1 do
begin
AutoZoom[i][0] := Self.Controls[i].Top / Self.Height;
AutoZoom[i][1] := Self.Controls[i].Left / Self.Width;
AutoZoom[i][2] := Self.Controls[i].Width / Self.Width;
AutoZoom[i][3] := Self.Controls[i].Height / Self.Height;
if Self.Controls[i].Font.Height = 0 then
Self.Controls[i].Font.Height := 80; //Font.Size
AutoZoom[i][4] := Self.Controls[i].Font.Height / Self.Width;
AutoZoom[i][5] := Self.Controls[i].Font.Height / Self.Height;
end;
end;
procedure TForm1.FormResize(Sender: TObject);
var
i: integer;
begin
for i := 0 to Form1.ControlCount - 1 do
begin
Self.Controls[i].Top := Round(AutoZoom[i][0] * Self.Height);
Self.Controls[i].Left := Round(AutoZoom[i][1] * Self.Width);
Self.Controls[i].Width := Round(AutoZoom[i][2] * Self.Width);
Self.Controls[i].Height := Round(AutoZoom[i][3] * Self.Height);
if Self.Width / Self.Height < FormAspect then
Self.Controls[i].Font.Height := Round(AutoZoom[i][4] * Self.Width)
else
Self.Controls[i].Font.Height := Round(AutoZoom[i][4] * Self.Height);
end;
end;
end.