Accessing .NET forms using the SESSION system handle
For GUI clients, ABL maintains a .NET form chain on the SESSION system handle that is analogous to the ABL window chain. This form chain links all .NET forms that you create in a session that are based on the OpenEdge form class, Progress.Windows.Form. The form chain is anchored to the SESSION handle at each end using the FIRST-FORM and LAST-FORM attributes. You can then use the NextForm and PrevForm properties on the Progress.Windows.Form class to walk the form chain similar to how you use the NEXT-SIBLING and PREV-SIBLING attributes to walk the ABL window chain.
However, note that the FIRST-FORM and LAST-FORM attributes actually have the Progress.Windows.IForm interface type, which Progress.Windows.Form implements. This interface defines the NextForm and PrevForm properties used to walk this chain so you can more naturally use .NET forms and ABL windows together. Thus, you can use this rIForm interface reference in the following example to walk the form chain:
DEFINE VARIABLE rForm AS CLASS Progress.Windows.Form NO-UNDO.
DEFINE VARIABLE rIForm AS CLASS Progress.Windows.IForm NO-UNDO.
DEFINE VARIABLE rDelForm AS CLASS Progress.Windows.IForm NO-UNDO.
rForm = NEW Progress.Windows.Form( ).
rForm:Text = "Market Quote 1".
rForm = NEW Progress.Windows.Form( ).
rForm:Text = "Market Search".
rForm = NEW Progress.Windows.Form( ).
rForm:Text = "Market Quote 2".
rIForm = SESSION:FIRST-FORM.
DO WHILE VALID-OBJECT( rIForm ):
rForm = CAST(rIForm, Progress.Windows.Form) NO-ERROR.
IF rForm <> ? THEN
IF rForm:Text BEGINS "Market Quote"
THEN
MESSAGE rForm:Text VIEW-AS ALERT-BOX INFORMATION.
rIForm = rIForm:NextForm.
END.
MESSAGE "End of Form Chain" VIEW-AS ALERT-BOX INFORMATION.
The iterative DO block in this example walks the chain looking for instances of Progress.Windows.Form. If this procedure is part of an application that also uses ABL windows, there can be a different type of form object on this chain (Progress.Windows.FormProxy) that is used to access these ABL windows. Thus, for each valid rIForm reference in the chain, if it cannot be cast to a Progress.Windows.Form, the ABL built-in CAST function returns the Unknown value (?). Otherwise, the cast succeeds, allowing the MESSAGE statement to display the Text property of an appropriate form object. For more information on using .NET forms with ABL windows, see Using.NET Forms with ABL Windows
Note: This example tests the result of the CAST function instead of the TYPE-OF function, because it is more efficient when used with .NET objects.
Note also that .NET forms, like all classes, appear on the session object chain anchored by the FIRST-OBJECT and LAST-OBJECT attributes of the SESSION system handle. So, you can also navigate them together with other class-based objects in an ABL session.
Note: Because System.Windows.Forms.Form does not implement Progress.Windows.IForm, if you use System.Windows.Forms.Form to create .NET forms in an ABL session, the form objects appear only on the session object chain. You also cannot use these native Microsoft form objects as a parent or child of an ABL window. For more information, see Using.NET Forms with ABL Windows for more information.