B4J Question Hide MainForm Border

Guenter Becker

Active Member
Licensed User
Longtime User
Hello,
I have an UNDECORATED Mainform. The loaded Layout has no Bordervalues.
If I show the Mainform I get this Screen:
1773582277755.png

I like to know what to do to hide the black Border (B4J).

I tried to use CSS / CSSUTILS FORMUTILS on the Mainform. Tried also TRANSPARENT style nothing helps border is still shown.
 

William Lancee

Well-Known Member
Licensed User
Longtime User
You can get rid of the border by using "UNDECORATED", but then you have add your own title bar.
If you need the form to be resizable, it becomes tricky - detect entry into the form - add resize handles etc.

noborders.jpg



'In Main
B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.SetFormStyle("UNDECORATED")
  
    MainForm.Show
    Dim PagesManager As B4XPagesManager
    PagesManager.Initialize(MainForm)
End Sub


B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.SetColorAndBorder(xui.Color_RGB(240, 240, 255), 0, 0, 15)
    Dim titleBar As B4XView = xui.createpanel("")
    titleBar.SetColorAndBorder(xui.Color_Blue, 0, 0, 15)
    Root.AddView(titleBar, 0, 0, Root.width, 60)
    Dim maskTitle As B4XView = xui.createpanel("")
    maskTitle.SetColorAndBorder(xui.Color_RGB(240, 240, 255), 0, 0, 0)
    Root.AddView(maskTitle, 0, 40, Root.width, 20)
    AddTitleIcon(2, Chr(0x00D7)) 
    AddTitleIcon(1, Chr(0x25A1)) 
    AddTitleIcon(0, Chr(0x2013)) 
End Sub

Private Sub AddTitleIcon(position As Float, character As String)
    Dim lbl As Label: lbl.initialize("Form")
    Dim lblx As B4XView = lbl
    lblx.Font = xui.CreateDefaultBoldFont(23)
    lblx.TextColor = xui.color_White
    lblx.Text = character
    lblx.Tag = position
    Dim w As Float = 23
    Dim left As Float = Root.Width - 3 * w + position * w
    Root.AddView(lblx, left, 2, w, w)
End Sub

Private Sub Form_MouseCLicked(ev As MouseEvent)
    Dim lbl As B4XView = Sender
    Select lbl.Tag
        Case 0    'Minimize
            Log("Min")
            MinMaxForm(True)
        Case 1    'Maximize  - since not resizable - this doesn't do anything
            Log("Max")
            MinMaxForm(False)
        Case 2    'Close
            Log("Close")
            ExitApplication
    End Select
End Sub

Public Sub MinMaxForm(Minimize As Boolean)
    B4XPages.GetNativeParent(Me)
    Dim jForm As JavaObject = B4XPages.GetNativeParent(Me)
    Dim stage As JavaObject = jForm.GetField("stage")
    stage.RunMethod("setIconified", Array As Object(Minimize))
End Sub
 
Last edited:
Upvote 0

Guenter Becker

Active Member
Licensed User
Longtime User

Attachments

  • B4JMainFormGUITemplate.zip
    116.3 KB · Views: 11
Upvote 0

Guenter Becker

Active Member
Licensed User
Longtime User
You can get rid of the border by using "UNDECORATED", but then you have add your own title bar.
If you need the form to be resizable, it becomes tricky - detect entry into the form - add resize handles etc.

View attachment 170613


'In Main
B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.SetFormStyle("UNDECORATED")
 
    MainForm.Show
    Dim PagesManager As B4XPagesManager
    PagesManager.Initialize(MainForm)
End Sub


B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.SetColorAndBorder(xui.Color_RGB(240, 240, 255), 0, 0, 15)
    Dim titleBar As B4XView = xui.createpanel("")
    titleBar.SetColorAndBorder(xui.Color_Blue, 0, 0, 15)
    Root.AddView(titleBar, 0, 0, Root.width, 60)
    Dim maskTitle As B4XView = xui.createpanel("")
    maskTitle.SetColorAndBorder(xui.Color_RGB(240, 240, 255), 0, 0, 0)
    Root.AddView(maskTitle, 0, 40, Root.width, 20)
    AddTitleIcon(2, Chr(0x00D7))
    AddTitleIcon(1, Chr(0x25A1))
    AddTitleIcon(0, Chr(0x2013))
End Sub

Private Sub AddTitleIcon(position As Float, character As String)
    Dim lbl As Label: lbl.initialize("Form")
    Dim lblx As B4XView = lbl
    lblx.Font = xui.CreateDefaultBoldFont(23)
    lblx.TextColor = xui.color_White
    lblx.Text = character
    lblx.Tag = position
    Dim w As Float = 23
    Dim left As Float = Root.Width - 3 * w + position * w
    Root.AddView(lblx, left, 2, w, w)
End Sub

Private Sub Form_MouseCLicked(ev As MouseEvent)
    Dim lbl As B4XView = Sender
    Select lbl.Tag
        Case 0    'Minimize
            Log("Min")
            MinMaxForm(True)
        Case 1    'Maximize  - since not resizable - this doesn't do anything
            Log("Max")
            MinMaxForm(False)
        Case 2    'Close
            Log("Close")
            ExitApplication
    End Select
End Sub

Public Sub MinMaxForm(Minimize As Boolean)
    B4XPages.GetNativeParent(Me)
    Dim jForm As JavaObject = B4XPages.GetNativeParent(Me)
    Dim stage As JavaObject = jForm.GetField("stage")
    stage.RunMethod("setIconified", Array As Object(Minimize))
End Sub
I'm very sorry but sometimes it is good to read the post carefully! I explained that I'am using UNDECORATED and that I'm not using B4XPages!. Therefor your answer does not meet my question.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
The three 'panes' you have in the layout each have a border, which is what you are seeing.

To remove the corners from the form it will need to be set to Style 'TRANSPARENT'
You will also need to add:
B4X:
        MainForm.RootPane.As(B4XView).Color = xui.Color_Transparent
        MainForm.BackColor = fx.Colors.Transparent

1773662586522.png
 
Last edited:
Upvote 0

Guenter Becker

Active Member
Licensed User
Longtime User
The three 'panes' you have in the layout each have a border, which is what you are seeing.

To remove the corners from the form it will need to be set to Style 'TRANSPARENT'
You will also need to add:
B4X:
        MainForm.RootPane.As(B4XView).Color = xui.Color_Transparent
        MainForm.BackColor = fx.Colors.Transparent

Thank you I did'nt recognize that there where Bordervalues of the panel. Deleted them and used your code proposal and know the problem is solved- Thank you.
 
Upvote 0
Top