1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
fRatio : Single;
procedure WMSizing(var Message: TMessage); message WM_SIZING;
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
uses Types;
{$R *.dfm}
{ TForm1 }
procedure TForm1.WMSizing(var Message: TMessage);
var
lprc: PRect;
begin
with Message do begin
lprc := PRect(LParam);
case Message.WParam of
WMSZ_TOP, WMSZ_BOTTOM, WMSZ_TOPRIGHT:
lprc^.Right := round( (lprc^.Bottom - lprc^.Top) / fRatio + lprc^.Left);
WMSZ_TOPLEFT :
lprc^.top := round( - fRatio * (lprc^.Right - lprc^.Left) + lprc^.bottom);
WMSZ_BOTTOMLEFT, WMSZ_BOTTOMRIGHT, WMSZ_RIGHT, WMSZ_LEFT:
lprc^.Bottom := round(fRatio * (lprc^.Right - lprc^.Left) + lprc^.Top);
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
with BoundsRect do
fRatio := (Bottom - Top)/(Right - Left);
end;
end. |
Partager