unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
lbSample: TLabel;
btTest: TButton;
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
private
fOrgWidth,
fOrgHeight : Integer;
fOrgFontHt : Integer;
fBtRect : TRect;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
fOrgHeight := Height;
fOrgWidth := Width;
fOrgFontHt := Font.Height;
fBtRect := btTest.BoundsRect;
end;
procedure TForm1.FormResize(Sender: TObject);
Var
txWd : Integer;
begin
font.Height := Muldiv (fOrgFontht,Height, fOrgHeight);
txWd := lbSample.Canvas.TextWidth(lbSample.Caption);
lbSample.Left := (width - txwd)
div 2;
btTest.left := muldiv (fBtRect.left, width, fOrgWidth);
btTest.Top := muldiv (fBtRect.Top, Height, fOrgHeight);
btTest.Width := muldiv (fBtRect.Right-fBtRect.left, width, fOrgWidth);
btTest.Height:= muldiv (fBtRect.Bottom-fBtRect.Top, Height, fOrgHeight);
end;
end.