Detecting Windows Application Close


Steven Burrows
 

We have a trap on the Exit event in one task with Propagate NO just-in-case a called program issues too many Exit events

However, when a user uses the big red X in the Top Right, this trap just loops.

 

Is there a way to detect that X being pressed ?

Tried “ KbGet(1)='Close Application'EVENT OR KbGet(1)='Exit System'EVENTin the propagate property to no effect

 

(XPA 4.8.1)

 

Steven Burrows

 


Harry Kleinsmit
 

Did you try trapping both the 'Close' and 'Exit' events?

Best regards,
Harry Kleinsmit.


Steven Burrows
 

Have tried Kbget(1) comparisons and Trapping the Events of:

Close, Close All, Close Application, Quit, and Exit System

Nothing gets triggered, just an Exit with no way to tell if it’s raised from the Task/Child or raised by the Menu X Shutdown mechanism. (Unless someone comes up with a clever idea)

 

For now, will just have to allow Propagate and cross fingers that nothing is using the Exit improperly. I know we had trouble with this task in the Unipaas/XPA2 days and unnecessary Exits were necessary to plaster over behavioural oddities, but AFAICT they have been removed when revamping for XPA4

Steven Burrows

 

From: main@magicu-l.groups.io <main@magicu-l.groups.io> On Behalf Of Harry Kleinsmit via groups.io
Sent: 02 November 2022 13:00
To: main@magicu-l.groups.io
Subject: Re: [magicu-l] Detecting Windows Application Close

 

 

Did you try trapping both the 'Close' and 'Exit' events?

Best regards,
Harry Kleinsmit.


sherman levine
 

Have you tried searching
how to disable close button in windows application

Also, for older Magic, Get.dll has a method for disabling the top right X, and that might still work for XPA
Sherm

On 11/2/2022 9:39 AM, Steven Burrows wrote:

Have tried Kbget(1) comparisons and Trapping the Events of:

Close, Close All, Close Application, Quit, and Exit System

Nothing gets triggered, just an Exit with no way to tell if it’s raised from the Task/Child or raised by the Menu X Shutdown mechanism. (Unless someone comes up with a clever idea)

 

For now, will just have to allow Propagate and cross fingers that nothing is using the Exit improperly. I know we had trouble with this task in the Unipaas/XPA2 days and unnecessary Exits were necessary to plaster over behavioural oddities, but AFAICT they have been removed when revamping for XPA4

Steven Burrows

 

From: main@magicu-l.groups.io <main@magicu-l.groups.io> On Behalf Of Harry Kleinsmit via groups.io
Sent: 02 November 2022 13:00
To: main@magicu-l.groups.io
Subject: Re: [magicu-l] Detecting Windows Application Close

 

 

Did you try trapping both the 'Close' and 'Exit' events?

Best regards,
Harry Kleinsmit.



Steven Blank
 

Steven,

The event that is raised when the user clicks the red X is 'Exit Application'ACT, not 'Exit'ACT.

KbGet() is a kludge. Creating an event handler that gets triggered by the Internal Event 'Exit Application'ACT (and NOT allowing it to Propagate) should turn the trick.
 
Steven G. Blank
Ξ SGBlank Consulting


On 11/2/2022 3:12 AM, Steven Burrows wrote:

We have a trap on the Exit event in one task with Propagate NO just-in-case a called program issues too many Exit events

However, when a user uses the big red X in the Top Right, this trap just loops.

 

Is there a way to detect that X being pressed ?

Tried “ KbGet(1)='Close Application'EVENT OR KbGet(1)='Exit System'EVENTin the propagate property to no effect

 

(XPA 4.8.1)

 

Steven Burrows

 



Steven Burrows
 

Tried “Close Application” and “Exit System” (there isnt an “Exit Application”) and they are not triggered.

A previously undisclosed fact is that the task is NOT in Main Context. My guess is that Main closes down other contexts using Exit, or at least none of the known events.

 

When I tried Activity Log to find the bug, I repeatedly got  the following until I killed the process with Task Manager. “MyTree” being the main control on the task with the Exit block.

<26313100721417420> 02/11/2022 09:41:54.945     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.946     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.946     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.947     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.947     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 

Steven Burrows

 

From: main@magicu-l.groups.io <main@magicu-l.groups.io> On Behalf Of Steven Blank via groups.io
Sent: 02 November 2022 16:35
To: main@magicu-l.groups.io
Subject: Re: [magicu-l] Detecting Windows Application Close

 

Steven,

The event that is raised when the user clicks the red X is 'Exit Application'ACT, not 'Exit'ACT.

KbGet() is a kludge. Creating an event handler that gets triggered by the Internal Event 'Exit Application'ACT (and NOT allowing it to Propagate) should turn the trick.
 

Steven G. Blank
Ξ SGBlank Consulting

On 11/2/2022 3:12 AM, Steven Burrows wrote:

We have a trap on the Exit event in one task with Propagate NO just-in-case a called program issues too many Exit events

However, when a user uses the big red X in the Top Right, this trap just loops.

 

Is there a way to detect that X being pressed ?

Tried “ KbGet(1)='Close Application'EVENT OR KbGet(1)='Exit System'EVENTin the propagate property to no effect

 

(XPA 4.8.1)

 

Steven Burrows


 

 


Steven Blank
 

Steven,

I usually try to test before replying, but didn't this time ... sorry. Correction:

The event that is raised when the user clicks the X in the upper-right corner of the MDI is 'Exit System'ACT, not 'Exit'ACT.
The event that is raised when the user clicks the X in the upper-right corner of the Program Form is 'Close'ACT, not 'Exit'ACT.

You will need to create three event handlers on each of these three events: 'Exit'ACT, 'Close'Act, and 'Exit System'ACT. You will also need to create three logical variables (called, for example, AllowExit, AllowClose, and AllowExitSystem), and reference these variables in the respective event handlers' Propagate properties.

In your program, you will need to set the values of these logical variables to frame the behavior you desire at runtime.

Steven G. Blank
Ξ SGBlank Consulting


On 11/2/2022 9:53 AM, Steven Burrows wrote:

Tried “Close Application” and “Exit System” (there isnt an “Exit Application”) and they are not triggered.

A previously undisclosed fact is that the task is NOT in Main Context. My guess is that Main closes down other contexts using Exit, or at least none of the known events.

 

When I tried Activity Log to find the bug, I repeatedly got  the following until I killed the process with Task Manager. “MyTree” being the main control on the task with the Exit block.

<26313100721417420> 02/11/2022 09:41:54.945     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.946     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.946     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.947     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.947     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 

Steven Burrows

 

From: main@magicu-l.groups.io <main@magicu-l.groups.io> On Behalf Of Steven Blank via groups.io
Sent: 02 November 2022 16:35
To: main@magicu-l.groups.io
Subject: Re: [magicu-l] Detecting Windows Application Close

 

Steven,

The event that is raised when the user clicks the red X is 'Exit Application'ACT, not 'Exit'ACT.

KbGet() is a kludge. Creating an event handler that gets triggered by the Internal Event 'Exit Application'ACT (and NOT allowing it to Propagate) should turn the trick.
 

Steven G. Blank
Ξ SGBlank Consulting

On 11/2/2022 3:12 AM, Steven Burrows wrote:

We have a trap on the Exit event in one task with Propagate NO just-in-case a called program issues too many Exit events

However, when a user uses the big red X in the Top Right, this trap just loops.

 

Is there a way to detect that X being pressed ?

Tried “ KbGet(1)='Close Application'EVENT OR KbGet(1)='Exit System'EVENTin the propagate property to no effect

 

(XPA 4.8.1)

 

Steven Burrows


 

 



Steven Blank
 

Two more things:

Timing is significant. An Event Handler's Propagate expression is not evaluated until after all of the operations in the Event Handler have been executed. Thus, you can perform tests, call other programs, and ultimately modify the value of the logical variable within the handler itself, because the Propagate expression will not be evaluated until afterward.

And I just noticed the context thing. No matter. If your program is called as a parallel program, then the handlers have to be defined in the called program, so their scope falls within the correct context. Depending on the behavior you're after, you might need to add some tests to global event handlers to text for the triggering context's ContextID. Context management is another topic for another day.

Steven G. Blank
Ξ SGBlank Consulting


On 11/2/2022 10:11 AM, Steven Blank wrote:

Steven,

I usually try to test before replying, but didn't this time ... sorry. Correction:

The event that is raised when the user clicks the X in the upper-right corner of the MDI is 'Exit System'ACT, not 'Exit'ACT.
The event that is raised when the user clicks the X in the upper-right corner of the Program Form is 'Close'ACT, not 'Exit'ACT.

You will need to create three event handlers on each of these three events: 'Exit'ACT, 'Close'Act, and 'Exit System'ACT. You will also need to create three logical variables (called, for example, AllowExit, AllowClose, and AllowExitSystem), and reference these variables in the respective event handlers' Propagate properties.

In your program, you will need to set the values of these logical variables to frame the behavior you desire at runtime.

Steven G. Blank
Ξ SGBlank Consulting


On 11/2/2022 9:53 AM, Steven Burrows wrote:

Tried “Close Application” and “Exit System” (there isnt an “Exit Application”) and they are not triggered.

A previously undisclosed fact is that the task is NOT in Main Context. My guess is that Main closes down other contexts using Exit, or at least none of the known events.

 

When I tried Activity Log to find the bug, I repeatedly got  the following until I killed the process with Task Manager. “MyTree” being the main control on the task with the Exit block.

<26313100721417420> 02/11/2022 09:41:54.945     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.946     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.946     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.947     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.947     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 

Steven Burrows

 

From: main@magicu-l.groups.io <main@magicu-l.groups.io> On Behalf Of Steven Blank via groups.io
Sent: 02 November 2022 16:35
To: main@magicu-l.groups.io
Subject: Re: [magicu-l] Detecting Windows Application Close

 

Steven,

The event that is raised when the user clicks the red X is 'Exit Application'ACT, not 'Exit'ACT.

KbGet() is a kludge. Creating an event handler that gets triggered by the Internal Event 'Exit Application'ACT (and NOT allowing it to Propagate) should turn the trick.
 

Steven G. Blank
Ξ SGBlank Consulting

On 11/2/2022 3:12 AM, Steven Burrows wrote:

We have a trap on the Exit event in one task with Propagate NO just-in-case a called program issues too many Exit events

However, when a user uses the big red X in the Top Right, this trap just loops.

 

Is there a way to detect that X being pressed ?

Tried “ KbGet(1)='Close Application'EVENT OR KbGet(1)='Exit System'EVENTin the propagate property to no effect

 

(XPA 4.8.1)

 

Steven Burrows


 

 




sherman levine
 

Steve,
Hijacking this thread
Do you know what's the difference between close and exit?
Thanks
Sherm

On 11/2/2022 1:11 PM, Steven Blank wrote:

Steven,

I usually try to test before replying, but didn't this time ... sorry. Correction:

The event that is raised when the user clicks the X in the upper-right corner of the MDI is 'Exit System'ACT, not 'Exit'ACT.
The event that is raised when the user clicks the X in the upper-right corner of the Program Form is 'Close'ACT, not 'Exit'ACT.

You will need to create three event handlers on each of these three events: 'Exit'ACT, 'Close'Act, and 'Exit System'ACT. You will also need to create three logical variables (called, for example, AllowExit, AllowClose, and AllowExitSystem), and reference these variables in the respective event handlers' Propagate properties.

In your program, you will need to set the values of these logical variables to frame the behavior you desire at runtime.

Steven G. Blank
Ξ SGBlank Consulting


On 11/2/2022 9:53 AM, Steven Burrows wrote:

Tried “Close Application” and “Exit System” (there isnt an “Exit Application”) and they are not triggered.

A previously undisclosed fact is that the task is NOT in Main Context. My guess is that Main closes down other contexts using Exit, or at least none of the known events.

 

When I tried Activity Log to find the bug, I repeatedly got  the following until I killed the process with Task Manager. “MyTree” being the main control on the task with the Exit block.

<26313100721417420> 02/11/2022 09:41:54.945     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.946     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.946     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.947     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.947     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 

Steven Burrows

 

From: main@magicu-l.groups.io <main@magicu-l.groups.io> On Behalf Of Steven Blank via groups.io
Sent: 02 November 2022 16:35
To: main@magicu-l.groups.io
Subject: Re: [magicu-l] Detecting Windows Application Close

 

Steven,

The event that is raised when the user clicks the red X is 'Exit Application'ACT, not 'Exit'ACT.

KbGet() is a kludge. Creating an event handler that gets triggered by the Internal Event 'Exit Application'ACT (and NOT allowing it to Propagate) should turn the trick.
 

Steven G. Blank
Ξ SGBlank Consulting

On 11/2/2022 3:12 AM, Steven Burrows wrote:

We have a trap on the Exit event in one task with Propagate NO just-in-case a called program issues too many Exit events

However, when a user uses the big red X in the Top Right, this trap just loops.

 

Is there a way to detect that X being pressed ?

Tried “ KbGet(1)='Close Application'EVENT OR KbGet(1)='Exit System'EVENTin the propagate property to no effect

 

(XPA 4.8.1)

 

Steven Burrows


 

 




Steven Blank
 

Hey, Sherm,

I BELIEVE that the only difference between Close and Exit is the source of the triggering event; I do NOT believe there is any difference in the outcome of the respective events.

Steven G. Blank
Ξ SGBlank Consulting


On 11/2/2022 10:34 AM, sherman levine wrote:

Steve,
Hijacking this thread
Do you know what's the difference between close and exit?
Thanks
Sherm

On 11/2/2022 1:11 PM, Steven Blank wrote:
Steven,

I usually try to test before replying, but didn't this time ... sorry. Correction:

The event that is raised when the user clicks the X in the upper-right corner of the MDI is 'Exit System'ACT, not 'Exit'ACT.
The event that is raised when the user clicks the X in the upper-right corner of the Program Form is 'Close'ACT, not 'Exit'ACT.

You will need to create three event handlers on each of these three events: 'Exit'ACT, 'Close'Act, and 'Exit System'ACT. You will also need to create three logical variables (called, for example, AllowExit, AllowClose, and AllowExitSystem), and reference these variables in the respective event handlers' Propagate properties.

In your program, you will need to set the values of these logical variables to frame the behavior you desire at runtime.

Steven G. Blank
Ξ SGBlank Consulting


On 11/2/2022 9:53 AM, Steven Burrows wrote:

Tried “Close Application” and “Exit System” (there isnt an “Exit Application”) and they are not triggered.

A previously undisclosed fact is that the task is NOT in Main Context. My guess is that Main closes down other contexts using Exit, or at least none of the known events.

 

When I tried Activity Log to find the bug, I repeatedly got  the following until I killed the process with Task Manager. “MyTree” being the main control on the task with the Exit block.

<26313100721417420> 02/11/2022 09:41:54.945     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.946     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.946     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.947     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.947     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 

Steven Burrows

 

From: main@magicu-l.groups.io <main@magicu-l.groups.io> On Behalf Of Steven Blank via groups.io
Sent: 02 November 2022 16:35
To: main@magicu-l.groups.io
Subject: Re: [magicu-l] Detecting Windows Application Close

 

Steven,

The event that is raised when the user clicks the red X is 'Exit Application'ACT, not 'Exit'ACT.

KbGet() is a kludge. Creating an event handler that gets triggered by the Internal Event 'Exit Application'ACT (and NOT allowing it to Propagate) should turn the trick.
 

Steven G. Blank
Ξ SGBlank Consulting

On 11/2/2022 3:12 AM, Steven Burrows wrote:

We have a trap on the Exit event in one task with Propagate NO just-in-case a called program issues too many Exit events

However, when a user uses the big red X in the Top Right, this trap just loops.

 

Is there a way to detect that X being pressed ?

Tried “ KbGet(1)='Close Application'EVENT OR KbGet(1)='Exit System'EVENTin the propagate property to no effect

 

(XPA 4.8.1)

 

Steven Burrows


 

 





sherman levine
 

Steve
Many thanks
Sherm


On 11/2/2022 2:03 PM, Steven Blank wrote:

Hey, Sherm,

I BELIEVE that the only difference between Close and Exit is the source of the triggering event; I do NOT believe there is any difference in the outcome of the respective events.

Steven G. Blank
Ξ SGBlank Consulting


On 11/2/2022 10:34 AM, sherman levine wrote:
Steve,
Hijacking this thread
Do you know what's the difference between close and exit?
Thanks
Sherm

On 11/2/2022 1:11 PM, Steven Blank wrote:
Steven,

I usually try to test before replying, but didn't this time ... sorry. Correction:

The event that is raised when the user clicks the X in the upper-right corner of the MDI is 'Exit System'ACT, not 'Exit'ACT.
The event that is raised when the user clicks the X in the upper-right corner of the Program Form is 'Close'ACT, not 'Exit'ACT.

You will need to create three event handlers on each of these three events: 'Exit'ACT, 'Close'Act, and 'Exit System'ACT. You will also need to create three logical variables (called, for example, AllowExit, AllowClose, and AllowExitSystem), and reference these variables in the respective event handlers' Propagate properties.

In your program, you will need to set the values of these logical variables to frame the behavior you desire at runtime.

Steven G. Blank
Ξ SGBlank Consulting


On 11/2/2022 9:53 AM, Steven Burrows wrote:

Tried “Close Application” and “Exit System” (there isnt an “Exit Application”) and they are not triggered.

A previously undisclosed fact is that the task is NOT in Main Context. My guess is that Main closes down other contexts using Exit, or at least none of the known events.

 

When I tried Activity Log to find the bug, I repeatedly got  the following until I killed the process with Task Manager. “MyTree” being the main control on the task with the Exit block.

<26313100721417420> 02/11/2022 09:41:54.945     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.946     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.946     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.947     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 <26313100721417420> 02/11/2022 09:41:54.947     [Action ] -         >>  Processing Event  [Exit]  Control Name :  [MyTree]

 

Steven Burrows

 

From: main@magicu-l.groups.io <main@magicu-l.groups.io> On Behalf Of Steven Blank via groups.io
Sent: 02 November 2022 16:35
To: main@magicu-l.groups.io
Subject: Re: [magicu-l] Detecting Windows Application Close

 

Steven,

The event that is raised when the user clicks the red X is 'Exit Application'ACT, not 'Exit'ACT.

KbGet() is a kludge. Creating an event handler that gets triggered by the Internal Event 'Exit Application'ACT (and NOT allowing it to Propagate) should turn the trick.
 

Steven G. Blank
Ξ SGBlank Consulting

On 11/2/2022 3:12 AM, Steven Burrows wrote:

We have a trap on the Exit event in one task with Propagate NO just-in-case a called program issues too many Exit events

However, when a user uses the big red X in the Top Right, this trap just loops.

 

Is there a way to detect that X being pressed ?

Tried “ KbGet(1)='Close Application'EVENT OR KbGet(1)='Exit System'EVENTin the propagate property to no effect

 

(XPA 4.8.1)

 

Steven Burrows