1

When you compile blank form and you try to resize it's width with mouse, it will stop probably, when it's clientwidth is near screen resolution width.

It is not possible set wider form even in designer. (Strange enough, I would never suppose it happens). I also played with Constraints too, but it is no solution either.

Is it possible to set Form.Width to 10000 pixel?

Sertac Akyuz
  • 54,131
  • 4
  • 102
  • 169
lyborko
  • 2,571
  • 3
  • 26
  • 54
  • What happens when you try to do this? – David Heffernan Jul 29 '18 at 17:37
  • @DavidHeffernan it stops widen, when you use mouse. And if you try to put the value 10000 in design time, it will be the highest possible value. – lyborko Jul 29 '18 at 17:43
  • I don't understand that. I know that the window manager won't let you resize larger than desktop size. But you can set the width programmatically. What happens when you do this? You can answer the question yourself. – David Heffernan Jul 29 '18 at 17:47
  • If you try to set the width of form programmatically (Form1.Width := 6000), it will not help. It will be still 1932 (1920x1080) – lyborko Jul 29 '18 at 18:04
  • I added information from your comment under the accepted answer and removed the duplicate status. – Sertac Akyuz Jul 30 '18 at 17:55

1 Answers1

4

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.

Sertac Akyuz
  • 54,131
  • 4
  • 102
  • 169
MBo
  • 77,366
  • 5
  • 53
  • 86