Page 1 of 1

Automatically fit form to resolution

Posted: Saturday 10th September 2022 6:40pm
by gambafeliz

I send you an example that depending on your resolution, you have to change the height of the window so that there is no going up or down. If they can't see it they will have to change the resolution to understand it.

My resolution for this example is 1600x1024

My question is, how can I start the application at a window size where the scroll bar does not exist?

It is possible that this is not well understood, I apologize if this is the case.


Re: Automatically fit form to resolution

Posted: Sunday 11th September 2022 7:06am
by thatbruce
Understood, and it's a good question.
Probably the answer lies in using MoveScaled in a Form_Open event handler.
There is a way to get the screen height but I can't find it at the moment. Maybe someone else can help here.
So what we want to do is use MoveScaled with x=0, y=0, height= the screen height and w=your design width.
BUT! This might not work too good if there is a top or bottom panel. :|

p.s. or a possibly stupid easy way is just to maximise the form. i.e just set the FullScreen property to true in the form designer.

Re: Automatically fit form to resolution

Posted: Sunday 11th September 2022 8:06am
by BruceSteers
I often have troubles with scrollview not being the size i expect it to be.

Question,, if you do not want the scroll bars then why use scrollview?

if you delete the scrollview container or change it into a scrollarea or a panel then the ContainerPanel works how you want it to and all fits in the screen. (see attached)


Re: Automatically fit form to resolution

Posted: Sunday 11th September 2022 8:18am
by gambafeliz
Hello thatbruce and BruceSteers

My most sincere thanks. cool

Look at the first answer it has inspired me and thanks to it I think I have found the solution.

Regarding the second one, I appreciate it but ScrollView is there for an important reason. And it is to visualize let's say a very long vertical sheet as if it were a web. Therefore changing the design is for me a patch.

Young and not so young, I am going to give you my solution and in turn my proposal:

Code: Select all

' this is the solution for our case (FMain.Open)
Me.Height = Desktop.Height

Code: Select all

' this solution is in the case that there is an HBox1 at the top (FMain.Open)
Me.Height = Desktop.Height - HBox1.Height
I hope you agree and if not please tell me a much better idea. Thank you very much