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
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().
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().
Works now!
Thanks Matt.
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.
Oops. That was a cut-and-paste error. I will edit my post to remove the extraneous WAIT-FOR.
The forum ate my post when I edited it. Awesome.
Welcome to our world! We're desperately seeking for a communities manager here ...