Try OpenEdge Now
skip to main content
Introducing the Progress Developer Studio for OpenEdge Visual Designer
Creating the Sports Window : Adding event handlers
 

Adding event handlers

The next step is to add the event methods. This is the code that starts the Customer, Department, and Purchase Order forms as children of the Sports 2000 form. At run time they appear embedded in the right pane of the Sports 2000 form.
Open sportsForm.cls in the ABL Editor and copy and paste the following event methods and event handler before the DESTRUCTOR statement:
METHOD PRIVATE VOID setAsChild (INPUT oChildForm AS Progress.Windows.Form, INPUT pcTitle AS character):
      oChildForm:MdiParent = THIS-OBJECT.
      oChildForm:Text = pcTitle. /*+ " [" + string(childFormNumber) + "]".*/
      oChildForm:FormClosed:SUBSCRIBE(Form_Closed).
      oChildForm:Show( ).
END METHOD.

METHOD PROTECTED VOID showCustomerForm (sender AS System.Object,
e AS System.EventArgs):
     DEF VAR oCBF AS openedge.tutorial.ui.customerForm.
     oCBF = NEW openedge.tutorial.ui.customerForm().
     childFormNumber = childFormNumber + 1.
     setAsChild(oCBF, 'Customer').
DELETE OBJECT e.
END METHOD.     /*showCustomerForm*/

METHOD PROTECTED VOID showDepartmentForm (sender AS System.Object,
e AS System.EventArgs):
     DEF VAR oDT AS openedge.tutorial.ui.departmentForm.
     oDT = NEW openedge.tutorial.ui.departmentForm().
     childFormNumber = childFormNumber + 1.
     setAsChild(oDT, 'Department').
DELETE OBJECT e.
END METHOD. /* showDepartmentForm */

METHOD PROTECTED VOID showPurchOrderForm (sender AS System.Object,
e AS System.EventArgs):
     DEF VAR oPO AS openedge.tutorial.ui.purchaseOrderForm.
     oPO = NEW openedge.tutorial.ui.purchaseOrderForm().
     childFormNumber = childFormNumber + 1.
     setAsChild(oPO, 'Purchase Order').
DELETE OBJECT e.
END METHOD.

METHOD PRIVATE VOID ultraExplorerBar1_ItemClick ( sender AS System.Object, e AS Infragistics.Win.UltraWinExplorerBar.ItemEventArgs ):
     DEF VAR cTag AS character NO-UNDO.
     cTag = STRING(e:Item:Tag).
     SESSION:set-wait-state('general').
     CASE cTag:
       WHEN 'CustMaint' THEN showCustomerForm(sender, e).
       WHEN 'Department' THEN showDepartmentForm(sender, e).
       WHEN 'PurchOrder' THEN showPurchOrderForm(sender, e).
     END CASE.
SESSION:set-wait-state('').
END METHOD. /* event handler */
Subscribe to the event that occurs when the user clicks an item on the Explorer Bar by selecting the UltraExplorerBar1 object in the Visual Designer. Find the ItemClick event on the Events tab in the Properties view, and add ultraExplorerBar1_ItemClick as the value.