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