-
Sequence of Form Events
In VFP forms events fire as LOAD, INIT, ACTIVATE when a form is created and then DESTROY, UNLOAD when a form is released. The form is not visible during the LOAD and INIT events.
Why does Lianja fire INIT first followed by LOAD? Also why is the form visible during the LOAD event?
-
-
I assume you are referring to VFP custom forms not Lianja pages, sections, fields and gadgets.
INIT() is the constructor. Without an object there are no methods.
So in Lianja the events fire in this order:
init()
load()
activate()
Q. why is the form visible during the LOAD event?
A. because it has been created already. LOAD() is called when the window is first activated just before ACTIVATE() is called. LOAD() could be moved before the window is first visible but I don't really see what difference that would make in code as the events are queued anyway and dispatched one at a time off the event queue.
-
In VFP we use the LOAD/UNLOAD event to open/close tables/cursors (when not using DataEnvironment). Controls are not yet created during the LOAD and already released during the UNLOAD.
So in Lianja it is recommended to open tables / create cursors (cursoradapter) in the Form INIT event? Are the Form container controls created in the INIT event or after? Which event would you use to close tables / cursors when the form is released?
-
Sub objects are already added before init() is called. If you look at a typical scx form in vfp you will see why. In many cases the sub objects are referenced from init(). I can see why load() is before init() now on a vfp form. I will look into moving it before init() but there will be no sub objects accessible until init() time.
-
Barry, my interest in the Form object through the scripting language is mostly due to the fact that this is key to present an interface with multiple windows.
I think many VFP migrations will use LOAD, INIT during creation followed by DESTROY, UNLOAD during release. LOAD and UNLOAD do not require any sub objects whereas INIT and DESTROY do. The Lianja INIT event works fine since sub objects are created and the form is not visible. If you move LOAD before INIT is it possible to add DESTROY and UNLOAD? UNLOAD is where you can close/release tables/cursors.
-
Hi Robert, rather than request this here it would be better to submit a ticket for an ER on Lianja.com. Destroy() and unload () are already there but not being called at the moment. Someone has already submitted a ticket for this and I am aware if this.
-
-
Quote:
Originally Posted by
robertjacobs
OK done. Thanks.
This order for custom components e.g. form has now been changed to:
LOAD()
INIT()
ACTIVATE()
where previously it was:
INIT()
LOAD()
ACTIVATE()
Note that no custom properties are available in LOAD() as the object has not yet completed construction ( INIT() has not yet been called ).