楼上朋友的方法不太好,改变窗体大小时会闪烁得很厉害。下面是我的一位朋友帮我写的,很不错的!
我拿出来给大家啦!顺便给大家拜年啦![
][
]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
procedure FormCanResize(Sender: TObject;
var NewWidth,
NewHeight: Integer;
var Resize: Boolean);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
bFromHight, bFromWidth: Boolean;
//bFromHight=true,宽度按照高度来修改
//bFromWidth=true,高度按照宽度来修改
procedure WMExitSizeMove(var Meg: TMessage);
message WM_EXITSIZEMOVE;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
{ TForm1 }
procedure TForm1.WMExitSizeMove(var Meg: TMessage);
begin
bFromHight := false;
bFromWidth := false;
end;
procedure TForm1.FormCanResize(Sender: TObject;
var NewWidth,
NewHeight: Integer;
var Resize: Boolean);
begin
if NewHeight <> Height then
if bFromWidth then
NewHeight := Trunc(NewWidth/1.5)
else
begin
NewWidth := Trunc(NewHeight*1.5);
bFromHight := true;
end
else
if NewWidth <> Width then
if bFromHight then
NewWidth := Trunc(NewHeight*1.5)
else
begin
NewHeight := Trunc(NewWidth/1.5);
bFromWidth := true;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Height := Trunc(Width/1.5)
end;
end.