Minimum window size?

Post your Gambas programming questions here.
Post Reply
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Minimum window size?

Post 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)
Me.Refresh
End
That almost works but it slips past the limits still somehow.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Minimum window size?

Post 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()

  Me.ShowModal

End


You will not be able to resize the Form smaller than set in the IDE, bigger is OK.
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Minimum window size?

Post 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
End
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.
Last edited by BruceSteers on Saturday 12th September 2020 10:03am, edited 2 times in total.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Minimum window size?

Post 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 
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Minimum window size?

Post 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.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Minimum window size?

Post 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.
If at first you don't succeed , try doing something differently.
BruceS
Post Reply