Try OpenEdge Now
skip to main content
GUI for .NET Mapping Reference
Mapping Reference Entries : OpenEdge GUI dialog compared to OpenEdge GUI for .NET dialog
 

OpenEdge GUI dialog compared to OpenEdge GUI for .NET dialog

The OpenEdge GUI provides two types of dialogs, a modal dialog box that you can display using a frame widget and a modal message box with several built-in options that you can display using a MESSAGE statement. The OpenEdge GUI for .NET provides a similar choice of dialogs with a richer set of options, one based on .NET forms and the other based on a message box that you can display using the Show( ) method of the MessageBox class.
The following table shows implementations for comparable dialogs using each type of GUI.
Table 4. OpenEdge GUI dialog compared to OpenEdge GUI for .NET dialog
OpenEdge GUI dialog
OpenEdge GUI for .NET dialog
DEFINE BUTTON bOK AUTO-ENDKEY DEFAULT
  LABEL "OK".
DEFINE FRAME frmCustomer
  "Hello, world!"
  bOK
  WITH FRAME frmCustomer
    DEFAULT-BUTTON bOK
    VIEW-AS DIALOG-BOX.

ENABLE ALL WITH FRAME frmCustomer.
VIEW FRAME frmCustomer.

WAIT-FOR WINDOW-CLOSE
  OF FRAME frmCustomer.
USING Infragistics.Win.Misc.*.
USING System.Windows.Forms.*.

DEFINE VARIABLE rForm
  AS Progress.Windows.Form.
DEFINE VARIABLE rLabel
  AS UltraLabel.
DEFINE VARIABLE rOKButton
  AS UltraButton.

rForm = NEW Progress.Windows.Form( ).
rLabel = NEW UltraLabel( ).
rOKButton = NEW UltraButton( ).

rLabel:Text = "Hello, world!".
rOKButton:Text = "OK".
rOKButton:Left = rLabel:Width + 1.
rOKButton:DialogResult1
  = DialogResult:Ok.
rForm:AcceptButton = rOKButton.
rForm:Controls:Add(rLabel).
rForm:Controls:Add(rOKButton).
rForm:Height = 3 * rOKButton:Height.
rForm:Width = rOKButton:Right + 10.

WAIT-FOR rForm:ShowDialog( ).
rForm:Dispose( )2
MESSAGE "Hello, world!"
  VIEW-AS ALERT-BOX.
USING System.Windows.Forms.*.

MessageBox:Show("Hello, world!").

1 Setting the DialogResult property of a button to an appropriate DialogResult enumeration value causes this value to be automatically assigned to the DialogResult property of the dialog-box Form class when the user clicks the button in the form. Setting this property on a modal form automatically causes the dialog box to close and the ShowDialog( ) method to return. If you do not set the DialogResult property on a button, you must handle a button event (such as Click) in order to explicitly set the property on the form and close the dialog box.

2 When a GUI for .NET dialog box closes, .NET does not garbage collect the dialog box object unless you also call the Close( ) method on the dialog box, which automatically calls the Dispose( ) method to prepare the object for garbage collection. When a dialog box closes, .NET hides it from view so it can be re-displayed without having to re-create the object. So, to ensure that .NET garbage collects a dialog box after it closes, you must call Dispose( ) on the object to tell .NET to garbage collect it.