unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
Left1,Left2,Left3:integer;
Top1,Top2,Top3:integer;
procedure WMMove(var Message: TWMMove)
message WM_MOVE;
end;
var
Form1: TForm1;
implementation
uses Unit2, Unit3;
{$R *.DFM}
procedure TForm1.WMMove(var Message: TWMMove);
begin
inherited;
if Assigned(Form2) then
begin
Form2.Top:=Form1.Top-Top1+Top2+30
// 30是偏差位置
Form2.Left:=Form1.Left-Left1+Left2+30
// 30是偏差位置
end;
if Assigned(Form3) then
begin
Form3.Top:=Form1.Top-Top1+Top3+60
// 60是偏差位置
Form3.Left:=Form1.Left-Left1+Left3+60
// 60是偏差位置
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Left1:=Form1.Left;
Top1:=Form1.Top;
Form2:=TForm2.Create(Self);
Left2:=Form2.Left;
Form3:=TForm3.Create(Self);
Top2:=Form2.Top;
Left3:=Form3.Left;
Top3:=Form3.Top;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
// 要顯示多個窗體,然後移動窗體就有效果了。
Form2.Show;
Form3.Show;
end;
end.