表單最大化時不佔滿全螢幕,而是限制在指定寬高與座標 (類似 Delphi IDE 主視窗行為)。
procedure WMGetMinMaxInfo(var Msg: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;Msg.MinMaxInfo^ 的 ptMaxSize (最大尺寸) 與 ptMaxPosition (最大化左上角)。
type
TForm1 = class(TForm)
private
procedure WMGetMinMaxInfo(var Msg: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;
end;
procedure TForm1.WMGetMinMaxInfo(var Msg: TWMGetMinMaxInfo);
begin
with Msg.MinMaxInfo^ do
begin
ptMaxSize.X := 800; // 最大化寬度
ptMaxSize.Y := 600; // 最大化高度
ptMaxPosition.X := 100; // 最大化左上角 X
ptMaxPosition.Y := 50; // 最大化左上角 Y
end;
Msg.Result := 0;
inherited;
end;
ptMinTrackSize 限制使用者拖曳的最小尺寸。