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 ?
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
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.
#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
B4X:
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