Closing a form from an ABL Window

Posted by ignace.sys@kluwer.be on 29-Sep-2017 03:07

I want to start a Form from an ABL Window. When closing the ABL Window i want to close the Form.
But i get "Invalid widget handle used in WAIT-FOR statement. WAIT-FOR terminated. (4122)"
We use Openedge 10.2B.

Sample code.

ABL Window:

DEFINE VARIABLE myViewer AS CLASS Viewer.

ON CLOSE OF THIS-PROCEDURE DO:
IF myViewer NE ? THEN myViewer:close().
RUN disable_UI.
END.

ON CHOOSE OF but-view IN FRAME DEFAULT-FRAME DO:
myViewer = NEW viewer().
myViewer:show().
myViewer:WAIT().
END.

Viewer.cls:

USING System.Windows.Forms.* FROM ASSEMBLY.

CLASS Viewer INHERITS Progress.Windows.Form:

METHOD PUBLIC VOID WAIT ():
WAIT-FOR Application:RUN( THIS-OBJECT ).
END METHOD.

END CLASS.


Thanks,

Ignace

Posted by Matt Gilarde on 29-Sep-2017 03:42

Your program needs to have one WAIT-FOR for the whole program. There should already be one in the ABL window procedure but you need to change it to be a GUI for .NET WAIT-FOR:

    WAIT-FOR System.Windows.Forms.Application:Run().

Remove the WAIT method from Viewer.cls and remove the call to myViewer:WAIT() from the but-view trigger.

To make the application stop cleanly you need to break the .NET WAIT-FOR with the following line at the end of the CLOSE OF THIS-PROCEDURE trigger:

   System.Windows.Forms.Application:Exit().

All Replies

Posted by Matt Gilarde on 29-Sep-2017 03:42

Your program needs to have one WAIT-FOR for the whole program. There should already be one in the ABL window procedure but you need to change it to be a GUI for .NET WAIT-FOR:

    WAIT-FOR System.Windows.Forms.Application:Run().

Remove the WAIT method from Viewer.cls and remove the call to myViewer:WAIT() from the but-view trigger.

To make the application stop cleanly you need to break the .NET WAIT-FOR with the following line at the end of the CLOSE OF THIS-PROCEDURE trigger:

   System.Windows.Forms.Application:Exit().

Posted by ignace.sys@kluwer.be on 29-Sep-2017 04:03

Works now!

Thanks Matt.

Posted by Laura Stern on 11-Oct-2017 07:48

Late reply as I was on vacation.  Glad this is working for you.  Yes, this will work.  But for the record, you do NOT need to use WAIT-FOR when you call Application:Exit().  And really you should not do that.  So you just need:

System.Windows.Forms.Application:Exit() in the trigger.

WAIT-FOR should only be used when the method blocks for I/O.  The Exit() method is not a blocking method.  Generally, the 2 .NET methods that need the WAIT-FOR are Application:Run() and ShowDialog() for a form.

Posted by Matt Gilarde on 11-Oct-2017 07:52

Oops. That was a cut-and-paste error. I will edit my post to remove the extraneous WAIT-FOR.

Posted by Matt Gilarde on 11-Oct-2017 07:54

The forum ate my post when I edited it. Awesome.

Posted by Mike Fechner on 11-Oct-2017 07:57

Welcome to our world! We're desperately seeking for a communities manager here ...

This thread is closed