B4J Question B4xPages -> Modal window?

TheRealMatze

Member
Licensed User
Hi,
next step on my lerning-agenda was "pages". Looks pretty much straight forward, and it´s the first time it works without exception.
Only three 1/2 things are missing for me.

When i start the b4j-version the new page opens in a new window. So far so good, but the other window is not locked. in vb i would open it as modal dialog, how can i simulate this?

How can i control the window-startup-position?

How can i control the "control-bar" (minimize, maximize, close)

How can i remove the <- Arrow in the b4a-version

Thanks
Matthias
 

Erel

Administrator
Staff member
Licensed User
Better to start a new thread for each question.

I recommend you to use B4XDialog for a dialog.

How can i control the window-startup-position?
B4X:
Dim form As Form = B4XPages.GetNativeParent(Me)
form.WindowsLeft = ...

How can i control the "control-bar" (minimize, maximize, close)
MainForm.SetFormStyle in Main module.

How can i remove the <- Arrow in the b4a-version
B4XPages.ShowPageAndRemovePreviousPages.
 
Upvote 0

TheRealMatze

Member
Licensed User
Ok
B4X:
    B4XPages.GetNativeParent(Me).SetFormStyle("UNDECORATED")
    Dim form As Form = B4XPages.GetNativeParent(Me)
    form.WindowLeft =200
    form.Windowtop =200

works pretty well, but

B4X:
B4XPages.ShowPageAndRemovePreviousPages

is not exact what i search for. I want to go back to the last page, but automaticly with B4XPages.ClosePage(Me) or with the hardware-button. i only want to remove the icon in the top...

Normaly i split questions, but these are all related to the b4xpage...
 
Upvote 0

Erel

Administrator
Staff member
Licensed User
Normaly i split questions, but these are all related to the b4xpage...
No. There are millions of questions that can be asked about B4XPages and they are not related.

It will be simpler to:
1. Call B4XPages.ShowPageAndClosePrevious instead of ClosePage.
2. Handle the CloseRequested event, cancel it and follow step #1.
 
Upvote 0

TheRealMatze

Member
Licensed User
Maybe i understand it wrong, but you mean the simplest way is to close the caller-window und open it again inside the closerequest-event? In this case the back button opens a new blank caller-window, so i have to log from which page the call comes and what data is entered in this page. Possible in 2 layers, but when the third comes... That's too much just to fulfill my view of aesthetics, so i let the arrow where it is...
 
Upvote 0

TheRealMatze

Member
Licensed User
I found a demo for setOwner which look like the equivalent to a modalForm.
It looks like B4XPages.GetNativeParent(Me) has also this function. Maybe this works, but i don´t know how to refer to the parent and the owner...
Can anybody give me a hint how to use it?
 
Upvote 0

William Lancee

Active Member
Licensed User
Based on a solution by @Cableguy, you can hide the title icon as follows:

B4X:
Private Sub hideTitleIcon
    Dim bc As BitmapCreator
    bc.Initialize(32, 32)
    For i = 0 To 31
        For j = 0 To 31
            bc.SetColor(i, j, xui.Color_Transparent)
        Next
    Next
    bc.SetColor(0, 0, xui.Color_White)
    B4XPages.GetNativeParent(Me).icon = bc.bitmap
End Sub

You can set the title text by in Page2 class:

B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    hideTitleIcon
    B4XPages.SetTitle(Me, "This is page 2 and note that there is no Icon")
End Sub

If you put the following in B4XMainpage (make sure to have B4XPages V1.08), page 2 will show first.

B4X:
Public Sub Initialize
    Dim p2 As page2
    p2.Initialize
    B4XPages.AddPage("p2", p2)
    B4XPages.showPage("p2")
End Sub

To go back to the Mainpage, use: B4XPages.showPage("MainPage") whenever you want.
 
Last edited:
Upvote 0

William Lancee

Active Member
Licensed User
You can also block the close event:

B4X:
Private Sub B4XPage_CloseRequest As ResumableSub
    Return False
End Sub

EDIT NOTE: This block is so effective that you can't close the app if this is the only window visible, and you haven't provided for other closure.
I had to use Task Manager.
 
Last edited:
Upvote 0

oparra

Well-Known Member
Licensed User
Here is a demo (B4A, B4J), which has helped me understand the use of B4Xpages.

which has helped me understand the use of B4Xpages in certain functionalities.

It is a simple login to a modal sale that accesses the main window.

But if you close the main window, you go back to the login page.

from where you can only exit applications.

P.S:
It is tested on B4J and B4A


I hope this helps..

1613013748618.png
1613013817310.png
 

Attachments

  • Project.zip
    17.9 KB · Views: 79
Last edited:
Upvote 0

William Lancee

Active Member
Licensed User
@oparra

Your example is very useful, but it took me a while to realize that you commented out a line in the standard B4XPages template

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

This is needed for the setting to "UTILITY" to work. Thanks for discovering that.
 
Upvote 0

oparra

Well-Known Member
Licensed User
@oparra

Your example is very useful, but it took me a while to realize that you commented out a line in the standard B4XPages template

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

This is needed for the setting to "UTILITY" to work. Thanks for discovering that.


' MainForm.Show (The problem is that in B4J it was throwing an error. )

My original intention was to create a splash and I saw that other things could be done, like a login.

Dim PagesManager As B4XPagesManager
PagesManager.Initialize(MainForm)

if you see that the Parameter of PagesManager is the form to later control the display of the form in B4XmainPage


Regards,
 
Last edited:
Upvote 0
Top