Automatically fit form to resolution

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
User avatar
gambafeliz
Posts: 13
Joined: Friday 2nd September 2022 7:50pm

Automatically fit form to resolution

Post by gambafeliz » Saturday 10th September 2022 6:40pm

Hello

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.

Thanks.
Attachments
demo.zip
(17.54 KiB) Downloaded 13 times
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)

User avatar
thatbruce
Posts: 35
Joined: Saturday 4th September 2021 11:29pm

Re: Automatically fit form to resolution

Post by thatbruce » Sunday 11th September 2022 7:06am

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. :|
hth
b

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.

BruceSteers
Posts: 887
Joined: Thursday 23rd July 2020 5:20pm

Re: Automatically fit form to resolution

Post by BruceSteers » Sunday 11th September 2022 8:06am

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)

BruceS
Attachments
demo-0.0.1.tar.gz
(11.9 KiB) Downloaded 8 times

User avatar
gambafeliz
Posts: 13
Joined: Friday 2nd September 2022 7:50pm

Re: Automatically fit form to resolution

Post by gambafeliz » Sunday 11th September 2022 8:18am

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
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)

Post Reply