What tells ABL to remove a form from the list?

Posted by jquerijero on 06-Nov-2009 14:20

After calling the Dispose method of the form object, the form listing still includes the form. I believe in .NET programming Dispose() should have the same expectation as calling the DELETE OBJECT in ABL.

NOTE: This is the SESSION form listing

All Replies

Posted by Laura Stern on 09-Nov-2009 09:39

Here's the answer regarding the form chain.  The AVM removes the form from the form chain when it is closed.  When a form is closed, Dispose is called automatically by .NET. But this is actually not relevant.  So it seems I am not seeing the behavior that you are.  Even if you called Dispose() yourself on the form - even if it is still on the screen (!), this will cause it to close and so the form will still be removed from the chain.  Can you give more details about what you are doing?

On your second statement - that calling Dispose() in .NET should have the same expectation as calling DELETE OBJECT in the ABL.  This is not the case.

Calling Dispose() is simply a way to tell an object to free up its resources. In native .NET, this has nothing whatsover to do with deleting (i.e., garbage collecting) the object.   Dispose only makes the object unuseable.  For example, if you tried to do myForm:Show() after closing a form, you'll get a System.ObjectDisposed exception. This illustrates that the object is still there (as the exception comes from the object itself); you just can't use it.  By contrast, using DELETE OBJECT in the ABL will delete the object (at least our side of a .NET extended ABL object).  It will do so regardless of whether there are any other references to it and therefore its destructor would run.

Posted by Laura Stern on 09-Nov-2009 09:45

P.S.  I hope you are not confused by the existence of a FormProxy on the form chain.  This is not your form.  If you give your form a title (i.e. by setting the Text property), and display ToString() on the objects on the form chain, you will (hopefully) see that your form is there while it is on the screen and no longer there after it is closed.  (ToString() on a form displays its name and title.)

Posted by jquerijero on 09-Nov-2009 10:04

Do you rely on Form_Closing/Form_Closed event or something else as Dispose (which you can use to close an open window) bypasses those events?

Posted by Laura Stern on 09-Nov-2009 10:41

Actually, on further inspection, we subscribe under the covers to FormClosed AND FormDisposed.  So either will remove it from the form chain.

Posted by jquerijero on 09-Nov-2009 15:17

Thanks Laura,

I'll check what I'm doing different.

Can you also verify this with the following scenarios (not urgent);

- This behavior with Infragistics MDI Tab Manager.

- The case when you use a form as child control. If you remove the border of a form and set it's TopLevel property to false, you can actually add it to another form and will be treated just like a regular widget (textbox).

Posted by Laura Stern on 10-Nov-2009 13:33

For the 2nd case - if you use a form as a control (no border, TopLevel = false), it is still put on the form chain and still removed in the same way - via either the Disposed or FormClosed events.   I don't know if Infragistics MDI Tab Manager is a form, but it certainly is not a Progress.Windows.Form.  Only Progress.Windows.Forms are put on the form chain in the first place.  That is one of the advantages you get from using our Form vs. the native System.Windows.Forms.Form.

Posted by jquerijero on 17-Nov-2009 17:09

Forms inside the IG's MDI Tab Manager, as long as it is derived from Progress.Windows.Form seems to get added into the session form list also.

This thread is closed