B4J Question Form inimum width and height without flicker?

MathiasM

Active Member
Licensed User
Hello

Is it possible to set a minimum widht and height of a form?
Now I do this by code, like this:
Code: Copy
If Width < 600 Then
       MainForm.WindowWidth = 600
   End If
   
   If Height < 600 Then
       MainForm.WindowHeight = 600
   End If

Which does exactly what it is supposed to do. But it flickers like hell when I'm trying to make the window smaller than the treshold value of 600.

Is there a more native way to fix this?

Thanks
 
try (uses JavaObject library)

You only need to set it once, the form will not be able to be thinner than the value you set.

Code: Copy
 Dim mj As JavaObject=Mainform
 mj.GetFieldJO("stage").RunMethod("setMinWidth",Array(500.0))
…
Note: the value in the array MUST be a Double, Int's won't work.

You can have setMinWidth, setMinHeight, setMaxWidth & setMaxHeight.
 
Last edited:
Upvote 0
You could also use the SetWindowSizeLimits method:
SetWindowSizeLimits(MinWidth As Double, MinHeight As Double, MaxWidth As Double, MaxHeight As Double)
like:
MainForm.SetWindowSizeLimits(500, 400, 1200, 800)
 
Upvote 0
That's indeed even better @klaus
Altough, this way I have to specify MaxWidth and MaxHeigth, while I have no real limits there. Could set it to 99999999999 I guess, no biggie.

Would make more sense to me as properties, not as a function. But hey, glad it exists native!

Thanks!
 
Upvote 0
Back
Top