Problem with Form Close-Event

Grolle

Member
Licensed User
Hi,

my programm build some subforms at runtime. I add the same close-event to every subform. If the programm run out of the IDE everything works fine but after compiling an optimized windows-exe the close-event do not run? Why? :sign0085:
Here is an example source for the problem:
B4X:
Sub Globals
End Sub
Sub App_Start
   AddForm("Form1", "Close-Test")
   AddEvent("Form1", Close, "Form1Close")
   Form1.Show
End Sub
Sub Form1_Close
   Msgbox("Normal-Close-Event")
End Sub
Sub Form1Close
       'This is the event I need at all the time!!!
   Msgbox("Common-Close-Event")
End Sub

Best regards,
grolle
 
Last edited:

agraham

Expert
Licensed User
Longtime User
Firstly it is not a good idea in Basic4ppc to have two different event Subs for the same event as you have in your code sample. Either use a compile time automatic (Name_Event) Sub or one added at runtime but not both. If you add more than one event Sub to an event you may get unexpected behaviour. I haven't bothered to analyse exactly what the problems might be but in general only one of the events Subs will be called and it might be indeterminate which one (but I'm not sure!).

In the case of Form.Close it looks like the optimising compiler AddEvents doesn't recognise that a Form has a Close event and a Form expects a Close event Sub to be name FormName_Close. I don't know if this behaviour is by design or an oversight but the IDE and an optimised application certainly behave differently which is not really desirable.
 
Last edited:

Grolle

Member
Licensed User
Hi and thanks for reply :),

are there any plans for the release date of the next version?

Best regards ...
 
Top