B4J Question [B4J] Minimize a form to icon (iconified)

Aldo's

Active Member
Licensed User
Trivial question: how do i minimize a B4XPage to an icon?
 

LucaMs

Expert
Licensed User
Longtime User
Trivial question: how do i minimize a B4XPage to an icon?
I answered right now in the Italian forum!
https://www.b4x.com/android/forum/t...d-icona-una-form-iconified.139541/post-883702

B4X:
Public Sub MinimizeForm(Frm As Form)
    Dim jForm As JavaObject = Frm
    Dim stage As JavaObject = jForm.GetField("stage")
    stage.RunMethod("setIconified", Array As Object(True))
End Sub

Esempio:
Private Sub Button1_Click
    MinimizeForm(B4XPages.GetNativeParent(Me).As(Form))
End Sub
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
I answered right now in the Italian forum!
https://www.b4x.com/android/forum/t...d-icona-una-form-iconified.139541/post-883702

B4X:
Public Sub MinimizeForm(Frm As Form)
    Dim jForm As JavaObject = Frm
    Dim stage As JavaObject = jForm.GetField("stage")
    stage.RunMethod("setIconified", Array As Object(True))
End Sub

Esempio:
Private Sub Button1_Click
    MinimizeForm(B4XPages.GetNativeParent(Me).As(Form))
End Sub
@LucaMs another time you saved my life.... Thanks

I post here some small code I managed to Minimize and Maximize the form from a Tray Bar:
B4X:
Dim PageButtonSettings As ButtonSettings
Dim PageProgAndScan As ProgAndScan

Sub TrayIcon1_DoubleClick
    Log("Double Click")    
    MaximizeForm(B4XPages.GetNativeParent(Me).As(Form)) ' If already maximized nothing happen
    MaximizeForm(B4XPages.GetNativeParent(PageProgAndScan).As(Form)) ' If already maximized nothing happen
End Sub

Public Sub MaximizeForm(Frm As Form)
    Dim jForm As JavaObject = Frm
    Dim stage As JavaObject = jForm.GetField("stage")
    stage.RunMethod("setIconified", Array As Object(False))
End Sub

Public Sub MinimizeForm(Frm As Form)
    Dim jForm As JavaObject = Frm
    Dim stage As JavaObject = jForm.GetField("stage")
    stage.RunMethod("setIconified", Array As Object(True))
End Sub

Sub TrayIcon1_MenuClick (txt As String)
    Select txt
        Case "Disattiva"
            TrayIcon1.SetImage(BlueImage)
            isActive = False
        Case "Attiva"
            isActive = True
            TrayIcon1.SetImage(GreenImage)
        Case "Esci"
            ExitApplication
    End Select
End Sub
This code can be adapted to just pass a B4XView.
Hope this help some users...
 
Last edited:
Upvote 0
Top