Results 1 to 9 of 9

Thread: Sequence of Form Events

  1. #1
    Member
    Join Date
    Feb 2012
    Location
    Ontario, Canada
    Posts
    98

    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?

  2. #2
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,184
    This thread has the loading order in Lianja: http://www.lianja.com/community/show...best-practices

    Hank


  3. #3
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,161
    Blog Entries
    22
    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.


    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  4. #4
    Member
    Join Date
    Feb 2012
    Location
    Ontario, Canada
    Posts
    98
    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?

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,161
    Blog Entries
    22
    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.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  6. #6
    Member
    Join Date
    Feb 2012
    Location
    Ontario, Canada
    Posts
    98
    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.

  7. #7
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,161
    Blog Entries
    22
    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.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  8. #8
    Member
    Join Date
    Feb 2012
    Location
    Ontario, Canada
    Posts
    98
    OK done. Thanks.

  9. #9
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,161
    Blog Entries
    22
    Quote Originally Posted by robertjacobs View Post
    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 ).
    Last edited by barrymavin; 2013-07-24 at 21:18.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us