Resolved How do I subscribe to an event anywhere in a WinForm class object?

Cecil

19+ years progress programming and still learning.
I have a WinFom class object (form.cls) that runs a legacy .p procedure (old.p) and it's not persistent.

In the old.p I want to publish an event i.e. publish "UpdateEvent" (input "Now Starting").

In the form.cls class object, how do I subscribe to the event "UpdateEvent" if I don't have a handle to the procedure?
 

Osborne

Active Member
I take it passing the WinForm class as a parameter to the old.p and then passing back the handle to the procedure is not an option?

If so, the only thing I can think of is put in extra workings in the old.p to link to the WinForm class and pass the handle to the procedure that way. E,g,:

Code:
DEFINE VARIABLE oForm AS Progress.Windows.Form NO-UNDO.
DEFINE VARIABLE oObject AS Progress.Lang.Object NO-UNDO.

ASSIGN oObject = SESSION:FIRST-OBJECT.
DO WHILE oObject <> ?:
   IF oObject:GetClass():TypeName = "form" THEN DO:
      oForm = CAST(oObject, "form").
      oForm:oldProcHandle = THIS-PROCEDURE.
      LEAVE.
   END.
   oObject = oObject:NEXT-SIBLING.
END.
 

Cecil

19+ years progress programming and still learning.
The solution I can up with was for form.cls to start a new persistent procedure (winformEventHandler.p ) passing in the object handle of the WinForm Class object (form.cls).

winformEventHandler.p was subscribed to events (anywhere) that were published by the old.p. Upon event being detected, winformEventHandler.p would invoke a method back to form.cls.

Once the old.p has returned back its response, I would close the winformEventHandler.p procedure. Job Done.

This meant I had minimal impact on the existing legacy old.p has I only needed to include published statements in the code.

old.p is being used in multiple places i.e. AppServers on Linux, Batch Jobs, and WIndows GUI sessions.
 
Top