Sample ABL-derived .NET non-modal form
- Last Updated: January 17, 2024
- 3 minute read
- OpenEdge
- Version 12.8
- Documentation
CurrentTimeForm is a sample ABL-derived non-modal form class that displays as in the following figure.

This form displays the current date and time every time you click the Time button and closes when you click the Close button.
This is the initial section of code where the class private data and public members are defined.
|
This block of code defines object references to the three controls from the
Ultra Controls for .NET provided with OpenEdge (see OpenEdge-installed .NET Controls). The public members include the DoWait( ) method, the CurrentTimeForm class constructor.
The DoWait( ) method
encapsulates execution of the WAIT-FOR statement
to make THIS-OBJECT the main form of the application
(see Block on non-modal forms). Therefore, if the application that invokes DoWait( ) contains
other .NET forms, they are all displayed and their events
are processed in the context of this WAIT-FOR statement.
The
constructor invokes the private InitializeComponent( ) method
to create and initialize the form and its controls.
This block of code is the beginning of the InitializeComponent( ) method.
|
It first instantiates, then initializes all
the objects for the form. For example, it assigns an initial current
date and time to the Text property of an Infragistics.Win.Misc.UltraLabel control.
As part of the initialization, it also sizes the form controls based
on their Text and Font settings,
and sets initial positions for the controls on the form based on
these sizes.
The initialization for each button also
includes a subscription to a corresponding PRIVATE event
handler that responds to the Click event on each
button (the TimeButton_Click( ) and CloseButton_Click( ) methods,
described in a following paragraph).
As a performance enhancement,
the method also suspends the publishing of layout events as the
form and its control objects are laid out. Applications do not typically
handle layout events during form initialization, if at all. So,
the SuspendLayout( ) method is often called
before initializing any layout logic, especially for forms and control
containers that might have many controls laid out within them.
This block of code is the end of the InitializeComponent( ) method.
|
This code initializes the form itself, adds
the controls to its control collection, and adjusts the size of
the form and the locations of its controls based on the control
sizes. Setting the AcceptButton property to the rTimeButton object
reference means that pressing the ENTER key
clicks the Time button. Finally, the method
resumes generation of layout events by calling ResumeLayout( ) on
the form, which allows the form layout to take effect.
Concluding
the ABL class definition are the PRIVATE event
handlers for the form.
|
The TimeButton_Click( ) event handler method responds to a
Click event on rTimeButton by updating the
Text property on the UltraLabel control
(rDateField) with the most recent date and time. The
CloseButton_Click( ) event handler responds to a Click
event on rCloseButton by invoking the Close( ) method of
the form. This both closes the form and also closes the application because it blocks on
THIS-OBJECT as the main form in the application using the
DoWait( ) method. (If the form was not displayed as a main form, the
application would have to call Application:Exit( ) to terminate the
application.)
CurrentTimeFromDriver.p is
the sample driver procedure (application) for the CurrentTimeForm sample class.
|
After instantiating the sample CurrentTimeForm class,
the application simply invokes its public DoWait( ) method
to do all the work. While this is a simple example, it shows how
an application can be simplified by encapsulating the processing
for a .NET form within the ABL-derived form object itself.