B4J Question Forms

moore_it

Well-Known Member
Licensed User
Longtime User
Hi all,

i've a program that close the mainform and open a new form.
When i close the new form i need to check the closerequest event but in the new form not run.
Why ?
Where i do wrong ?

Thanks in advice
 
Works fine here:
Code: Copy
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Dim frm2 As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.RootPane.LoadLayout("1") 'Load the layout file.
   MainForm.Show
   frm2.Initialize("frm2", 300, 300)
   frm2.Show
End Sub

Sub frm2_CloseRequest (EventData As Event)
   Log("request")
   EventData.Consume
End Sub
 
Upvote 0
This also works fine:
Code: Copy
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Dim frm2 As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.RootPane.LoadLayout("1") 'Load the layout file.
   MainForm.Show
   frm2.Initialize("frm2", 300, 300)
   frm2.Show
   Sleep(100)
   MainForm.Close
End Sub

Sub frm2_CloseRequest (EventData As Event)
   Log("request")
   EventData.Consume
End Sub

Help us help you. Take this code and modify it as needed to reproduce the problem.
 
Upvote 0
I think when i initialize a new class and open a new form in it closing the mainform the event closerequest of the new form not run ...
 
Upvote 0
Main
Code: Copy
#Region Project Attributes
    #MainFormWidth: 1024
    #MainFormHeight: 1024
#End Region

Sub Process_Globals
    Private MainForm As Form
    
    Private Class As Class1
    
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    Form1.Close
    
    Class.Initialize
        
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Class1
Code: Copy
Sub Class_Globals
    Private fx As JFX
    Dim frm As Form
End Sub

'Initialisiert das Objekt. Falls nötig kannst du Parameter zu dieser Methode hinzufügen.
Public Sub Initialize

    frm.Initialize("frm", 300, 300)
    frm.Show

End Sub

Sub frm_CloseRequest (EventData As Event)
    
    Log("frm_CloseRequest")
    
    EventData.Consume
    
    frm.Close
    
End Sub
 
Upvote 0
Back
Top