Common focus detection for forms and windows
- Last Updated: January 17, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Using the traditional OpenEdge GUI, the ACTIVE-WINDOW system handle returns the
handle of the last non-modal ABL window to generate an ENTRY event
(that is, the last window to receive focus). If you use .NET forms,
you can use the static ActiveForm property on System.Windows.Forms.Form to
return the object reference to the last non-modal form to receive
focus. However, when you use .NET forms and ABL windows together,
you cannot use these two mechanisms to reliably determine the most
recent non-modal form or window to receive focus. If a form is the
last to receive focus, ACTIVE-WINDOW returns the Unknown value (?),
and if a window is the last to receive focus, the static ActiveForm property
returns an object reference with no meaning to the ABL session context.
Instead, to identify the last form or window to receive focus,
ABL provides the ACTIVE-FORM system
reference. ACTIVE-FORM returns a Progress.Windows.IForm interface
reference to a form object on the form chain (see ABL session architecture for forms and windows). Thus, depending on the object that received
the last focus, ACTIVE-FORM can return a reference
to a .NET form object instantiated from Progress.Windows.Form (or
a derived class)) or a reference to the Progress.Windows.FormProxy object
associated with an ABL window that you have created in the session.
ACTIVE-FORM to reliably
return the object reference to each .NET form that receives focus in an ABL session, you
must create all .NET forms from Progress.Windows.Form
(or a derived form, never
System.Windows.Forms.Form).If last focus is in the client area of an embedded ABL window, ACTIVE-FORM returns
a Progress.Windows.IForm reference to the Progress.Windows.Form (or
derived form) that embeds the ABL window. For more information,
see Embed ABL windows in .NET forms.
If ACTIVE-FORM returns a Progress.Windows.Form,
you can then access the form class members by casting its Progress.Windows.IForm reference.
If ACTIVE-FORM returns a Progress.Windows.FormProxy,
you can access the ABL window it is associated with using the window
handle returned by its ProWinHandle property.
ACTIVE-FORM returns the Unknown value (?),
because ABL doesn't create a FormProxy object for
the default window.