How to close the child window when its parent is closed

rajeshatl

New Member
Hi ,
could you anyone please explain how to close the child window when try to close the parent window.(In ADM2 window)

In my code, In first time I try to close the parent window I can able to close the child window , but in the same session I try to open the same window(parent) it not able to open . Its crashing somewhere. I think the problem is not closed the child window properly. Could anyone explain how to close the child window properly.
 
I should have been more clear on my question:

The interesting information is what is the exact code that starts the child window:
Does it RUN the child window persistently or not?

If it does not then you will end up having more than one active WAIT-FOR in your session which explains why the session crashes. If that's the case then you must change the code to run the child window persistently and then it will automatically be closed when you close the parent window.

Heavy Regards, RealHeavyDude.
 
thanks for ur reply... I start the window without using the keyword persistent like
run child_win.w(input parm1,input parm2) no-error .
Could you please explain how can I avoid the crashing.
 
in the calling statement I have also passing the handle of the parent window .
run child_win.w((INPUT locWinId, INPUT user, INPUT winHandle) no-error .
 
Your problem is that a Progress session is only able to cope with exactly one WAIT-FOR at a given time. If you look into the main block of a window you will see code that branches on the THIS-PROCEDURE:PERSISTENT attribute. All you need to do to fix this is to run your window persistently.

RUN child_win.w (INPUT ..., INPUT ..., INPUT ... ) PERSISTENT NO-ERROR.

Have a look into the documentation to be able to decide whether you should set the handle of the persistently started procedure in order to access it later on or not.

Heavy Regards, RealHeavyDude.
 
thanks for your valuable reply...
I have used persistent keyword while calling the window but it seems the problem still exist.
I used like this
RUN child_win.w (INPUT ..., INPUT ..., INPUT ... ):PERSISTENT NO-ERROR.
 
In theory every procedure started persistently from another procedure should get closed gracefully automatically when that other procedure ends. In theory - because we all know that sometimes things don't work out like they should ...

Plus I am a control freak: Means I want to have as much control as possible about what happens in an application I develop - therefore I would introduce code that takes care of such things.

1. Start the procedure persistently and store the handle some where ( on a variable - maybe later on in a Temp-Table ).
DEFINE VARIABLE hMyProcedure AS HANDLE NO-UNDO.
RUN your_procedure ( INPUT ..., INPUT ..., OUTPUT ... ) PERSISTENT SET hMyProcedure.

1. As you are talking 'bout ADM2 I'll take it that the parent procedure is a smart window: In an override of destroyObject in the smart window.
IF VALID-HANDLE ( hMyProcedure ) THEN
RUN destroyObject IN hMyProcedure.

RUN SUPER.

As an alternative to starting the child window "manually" using RUN you could place it on an unused container page of the parent window and in the logic that fires when the menu is selected just view the corresponding page. That way the ADM2 will take care for handling the window and closing it gracefully when you close the parent window.

Heavy Regards, RealHeavyDude.
 
Back
Top