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
Top