type
TForm1 = class(TForm)
.....
public
offsetX, offsetY: Integer;
// 保存form2与form1的偏移值
private
procedure WMWindowPosChanged(var Msg: TWMWindowPos);
message WM_WINDOWPOSCHANGED;
end;
....
procedure TForm1.WMWindowPosChanged(var Msg: TWMWindowPos);
begin
inherited;
form2.top := form1.top + offsetx;
form2.left := form1.left + offsety;
end;