B4J Question FormLV.Resizable = False Problem Solved

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All

Below is the code I use to create a Form and display an Image. As I don't want the user to resize the window I have used "Form.Resizable = False", unfortunately this resizes the Form slightly before locking the size. [See the two attached images]
Originally I thought it might be a timing issue but using a timer to delay "FormLV.Resizable = False" by a second did not help.

Does anyone have an answer to this?:confused:

Regards Roger

GoodResult.png BadResult.png

B4X:
Sub BtnFiles_action
    If File.Exists(DirPath, "") = False Then File.MakeDir(DirPath, "")
'Find files. Select file to import
    Private Image1 As Image
    Private FileChooser1 As FileChooser
   
    FileChooser1.Initialize
    FileChooser1.Title = $"Saved Files"$
    FileChooser1.InitialDirectory = DirPath
    Filename1 = FileChooser1.ShowOpen(MainForm)
    Filename1 = Filename1.Replace(DirPath, "")
    If Filename1 <> "" Then
        Image1.initialize(DirPath, Filename1)
        FormLV.Initialize("", Image1.Width, Image1.Height)
        FormLV.SetFormStyle("DECORATED")
        FormLV.Title = Filename1
        FormLV.RootPane.Style = "-fx-background-image: url('" & File.GetUri(DirPath, Filename1) & "');"
        FormLV.Show
        'FormLV.Resizable = False
    End If
End Sub
 

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All,

Worked around problem using "Form.SetWindowSizeLimits(MinWidth As Double, MinHeight As Double, MaxWidth As Double, MaxHeight As Double)" in place of "Form.Resizable".

Code below:

B4X:
Sub BtnFiles_action
    If File.Exists(DirPath, "") = False Then File.MakeDir(DirPath, "")
'Find files. Select file to import
    Private Image1 As Image
    Private FileChooser1 As FileChooser
   
    FileChooser1.Initialize
    FileChooser1.Title = $"Saved Files"$
    FileChooser1.InitialDirectory = DirPath
    Filename1 = FileChooser1.ShowOpen(MainForm)
    Filename1 = Filename1.Replace(DirPath, "")
    If Filename1 <> "" Then
        Image1.initialize(DirPath, Filename1)
        FormLV.Initialize("", Image1.Width, Image1.Height)
        FormLV.SetFormStyle("DECORATED")
        FormLV.Title = Filename1
        FormLV.RootPane.Style = "-fx-background-image: url('" & File.GetUri(DirPath, Filename1) & "');"
        FormLV.Show
       
        FormLV.SetWindowSizeLimits(FormLV.windowWidth, FormLV.windowHeight, 0, 0)
       
    End If
End Sub

Regards Roger
 
Upvote 0
Top