Minimum window size?

Post

Posted
Rating:
#1 (In Topic #457)
Guru
BruceSteers is in the usergroup ‘Guru’
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

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.
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
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.

Code (gambas)

  1. Public Sub _new()
  2.  
  3.   Me.ShowModal
  4.  
 
You will not be able to resize the Form smaller than set in the IDE, bigger is OK.
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’
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

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.
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Guru
cogier is in the usergroup ‘Guru’
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: -

Code (gambas)

  1. If Me.width < 200 Then hLCDLabel.hide Else hLCDLabel.Show
Online now: No Back to the top

Post

Posted
Rating:
#5
Guru
BruceSteers is in the usergroup ‘Guru’
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.
Online now: No Back to the top

Post

Posted
Rating:
#6
Guru
BruceSteers is in the usergroup ‘Guru’
 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.
Online now: No Back to the top
1 guest and 0 members have just viewed this.