B4J Question Disable form resizing by dragging corners

nima66

Member
Is it possible to keep the maximize button enabled but prevent the user from resizing the form by dragging the corners?
I want the form to have only two states.
In the default state, it should be the size I want. For example 500*800
If you select the maximize button, the form will be full screen.
If it is full screen and the maximize button is clicked, it will return to the size of 500*800.
I tried everything, but I couldn't. I also asked chatGPT but they sent me wrong codes.
 

nima66

Member
I wrote this code
But when the form size is changed by dragging the form corners, there is a lot of jumping.

B4X:
Public Sub Initialize
    Private getFormPosition() As String = Regex.Split(",", func.getFormPosition)
    form.Initialize("form", getFormPosition(2), getFormPosition(3))
    form.Title="test"
    form.Icon = fx.LoadImage(File.DirAssets, "icon.png")
    func.CenterForm(form)
    form.Show
    FixedWidth=form.WindowWidth
    FixedHeight=form.WindowHeight
End Sub

Sub IsMaximized(frm As Form) As Boolean
    Dim joForm As JavaObject = frm
    Dim joStage As JavaObject = joForm.GetField("stage")
    Dim Maximized As Boolean = joStage.RunMethod("isMaximized", Null)
    Return Maximized
End Sub

Private Sub form_Resize (Width As Double, Height As Double)
    If Not(IsMaximized(form)) Then
        If form.Width<>FixedWidth Or form.Height<>FixedHeight Then
            form.WindowWidth = FixedWidth
            form.WindowHeight = FixedHeight
        End If
    End If
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…