Topic: Automatic Form Size

I have a form that is 800 x 540
Is there any way to have the form open up to the full screen size of the users computer?
-
I have sizeable = true so I get the Min Max buttons but when I click on Max the application does fill the screen, but the form stays at 800 x 540
-
I know I can make the form size bigger to fill most of my laptop screen - about 1250 x 650 but if someone has a larger monitor the form will stay at 1250 x 650
-
Is there any "standard" form size that is recommended for an MVD program? Any thoughts on sizing my forms will be appreciated.
-
Thanks, Frank

2 (edited by CDB 2020-09-29 09:31:28)

Re: Automatic Form Size

You can check for screen.width and screen.height.


I have found though that this fails if someone uses a high magnification in Windows 10 such as 150%. This would appear to be a combination of Windows  and the early version of Delphi used  behind MVD.


You could try in conjunction with the constraints property of a form and components:

procedure frmMain_OnResize (Sender: TObject);

begin

  frmMain.Left := (screen.width - frmMain.width) div 2;
  frmMain.Top := (screen.height - frmMain.Height) div 2;

end;

I should mention that the above code centres the form in the middle of the screen

On a clear disk you can seek forever

Re: Automatic Form Size

Hello papfranck, Hello cdb

You could have a look on thi link :

https://www.thoughtco.com/multi-resolut … ns-1058296

JB

Re: Automatic Form Size

Jean & CDB,

Thanks for your suggestions.  Unfortunately I'm struggling.  CDB, I've tried adding your procedure to my script file but it doesn't seem to do much.  You mention using the code in conjunction with Constraints.  My constraints are all set to 0 and I'm not sure what effects they will have if I change them.
-
Jean, I took a look at the article you mentioned and there's a lot of info there.  I tried a couple of things but nothing seemed to help.
-
Here's where I am at so far:
I have 2 laptops.  One is slightly larger than the other.  I've been programming on the larger one.  And when I take the program to the smaller one it's too big for the screen.  Also the smaller one has the task bar at the top of the screen.  With the task bar at the top it covers up the sizeable bar at the top of my program.  So I'm not able to click on the X to exit the program.  When I move the task bar to the bottom it exposes the sizeable taskbar and I'm now able to close the program.
-
I was looking around and I noticed something on the Laptops.
I opened up Windows Explorer and with the taskbar at the bottom the Explorer screen was OK.
-
Then when I moved the taskbar to the top of the screen, the Explorer automatically moved down slightly so the sizeable icons are visible.
-
I guess what I'm hoping for is for my MVD program to behave like that.
-
I've been experimenting with the property settings for my main form and I'm not having any luck.
-
I can make my application smaller so it will fit on the smaller computer screen, but then when I maximize it the background fills the screen but the form stays the same size.
-
I may be missing something here but so far I'm not making any progress.
-
Your thoughts will be appreciated as alway.
Thanks, Frank

Re: Automatic Form Size

papafrank,

Did you just copy and paste my example or did you double click on your main forms' resize event and then enter the code?

I think you ought to move the code to the forms ON SHOW event, rather than the resize one.

On a clear disk you can seek forever

Re: Automatic Form Size

CDB,
Thanks for getting back to me.
-
I did what you asked and I still have a problem.  I'm probably missing something simple?
-
Here's what I did: I created a simple one form project.  I set the size of the form to 1400 x 900. This size is bigger than my laptop screen.
I put a label and a text field on each side and top and bottom of the form.
When I run the program the right and bottom fields are not visible because the form is too big for my laptop.
-
I've attached a copy of my project.  Maybe you could take a look and let me know what you think.
-
Thanks, Frank

Post's attachments

Attachment icon 8-TestForm.zip 334.98 kb, 261 downloads since 2020-09-30