Page 1 of 1

Minimum window size?

Posted: Wednesday 09th September 2020 8:10pm
by BruceSteers
Hi all.

Is it possible to set a minimum window size so the form cannot shrink below the size of not being able to render controls properly and pumping out error messages?

I've tried using the Form_Resize() event to resize the window if it gets too small but it doesn't work.

Code: Select all

Public Sub Form_Resize()
Me.Width = Max(Me.Width, 600)
Me.Height = Max(Me.Height, 300)
That almost works but it slips past the limits still somehow.

Re: Minimum window size?

Posted: Thursday 10th September 2020 12:28pm
by cogier
Hi Bruce,

If the window is a new window set the minimum size in the IDE then open it with 'MyForm.ShowModal'.

If this is your main Form then, as above, set the minimum size in the IDE then add the following code to your program.
Public Sub _new()



You will not be able to resize the Form smaller than set in the IDE, bigger is OK.

Re: Minimum window size?

Posted: Friday 11th September 2020 10:13am
by BruceSteers
Thank you Cogier
sadly now i've got a HSplt that's not initialising as it was and i can't seem to change it
also i'm getting a segmentation error when closing the app :(
I'll play some more and see if i can figure it out as i'm loving the way the form can't go any smaller.
We need to ask Ben for a Form.MiniminWitdth , Form.MinimumHeight setting i think. really needs one.

Best solution i have so far is this...

Code: Select all

Public Sub Form_BeforeArrange()
If Me.Width < 600 Then Me.width = 600
If Me.Height < 350 Then Me.Height = 350
By using that method the form is still going smaller than it should :( but the controls are not and i'm not getting any errors :)

Edit. I've altered the code above to exclude the Form_Resize() event code as it wasn't needed , just the Before_Arrange() event code can make the controls stop pumping out errors.

Re: Minimum window size?

Posted: Friday 11th September 2020 1:50pm
by cogier
I had this trouble with my program 15PuzzleGame. If the LCDLabel got too small it created an error and crashed the program so I used: -
If Me.width < 200 Then hLCDLabel.hide Else hLCDLabel.Show 

Re: Minimum window size?

Posted: Saturday 12th September 2020 10:00am
by BruceSteers
I've sent Ben the code and said pretty pretty please can we have a MinimumWidth & height setting :)
Would sure save a lot of messing about.
I couldn't use ShowModal without the segmentation fault 11

I even tried the SM_integer=Me.SowModal and Me.Close(SM_integer) still same error.
Ben now has the code and is looking over it.

Re: Minimum window size?

Posted: Sunday 13th September 2020 8:43pm
by BruceSteers
From what I've read a "modal" window behaves differently to a normal one, it doesn't even trigger events apparently, just allows the user to input data and have the data on close. So I dont think I can use that method anyway.
Thanks anyway.