Window size is limited by system - you can retrieve this value using function GetSystemMetrics(SM_CXMAXTRACK)
- it is 1292 for my 1280x1024 display.
To allow your form be wider, you can treat message WM_GETMINMAXINFO
providing desired max size:
procedure WMGETMINMAXINFO(var M: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;
...
procedure TForm1.WMGETMINMAXINFO(var M: TWMGetMinMaxInfo);
begin
M.MinMaxInfo.ptMaxTrackSize.X := 5000;
M.Result := 0;
inherited;
end;
With such message handler I am able to set Width := 5000;
successfully in runtime.
Normally you should be able to use Constraints
property of the form and set its MaxWidth
to achieve this as in this answer but WM_GETMINMAXINFO
of TCustomForm
is defective in Delphi 7. Calling of ConstrainedResize
method from the message handler depends on some FSizeChanging
boolean field, which unfortunately is never set to true. This is corrected and the field is removed somewhere in between D2007 and DXE.