Highlighted
Absent Member.
Absent Member.
450 views

[archive] Trapping Windows Shut Down

[Migrated content. Thread originally posted on 28 November 2007]

Does anyone know how to trap the Windows Shut Down so that I can either prompt the user to sign out of the Acu application, or either terminate my acu application tidily before the op system has shut down, or stop the shut down completely whilst the application is running?
0 Likes
7 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Trapping Windows Shut Down

The only tool I know of in this area is the Abend Diagnostic Report. But that really isn't what you are looking for, I don't think.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Trapping Windows Shut Down

No - I do not think that's what I need.

When you shut down Windows, it causes a tidy shutdown of MS Office and other active applications that seem to know what the trick is. I do not know what the trick is !:(
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Trapping Windows Shut Down

Hi,
if I've understand well the problem (trapping Win Shutdown) maybe QUIT_MODE config. variable setted to a > 0 value can help You:
see AcuGt manual book 4 sez. H.2 for more explanations.
bye Gio.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Trapping Windows Shut Down

QUIT_MODE only affetcs the way the run-time reponds to user requests for closing main windows etc.

'Windows' must be nofifying running applications in some way that it intends to shut down - but I do not know how it does that or how Acu run-time can detect the condition.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Trapping Windows Shut Down

Ok but manual says:
"If you start your program in "safe" mode with the "-s" runtime option, then QUIT_MODE will be initialized to "-2" instead of "0". This prevents the user from using the Close menu item. A QUIT_MODE entry in the configuration file takes precedence over the default handling of "-s".

If a user attempts to end the Windows session when it is not allowed, a pop-up message box asks the user to terminate the application first. You can customize the message that appears in the box by setting the TEXT configuration variable, message number 18."
so it seems that trying to close system Session can be trapped by runtime and than react to it.
Some more: when system ask shutdown send a WM_DESTROY message to all existing windows so can't you try to catch MSG-CLOSE event on app main window and than reject it setting event-action to event-action-fail to prevent closing?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Trapping Windows Shut Down

Thanks - that has got me somewhere. Setting QUIT_MODE to -2 does bring up a dialogue box showing message 18 but does not inhibit the windows dialogue coming up seconds later giving the option to shut down irrespective of the condition. It would be great to stop that happening - is this what you talking about with the WM_DESTROY message ? If so how can that be trapped in my program(s)?

Keith
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Trapping Windows Shut Down

Well, WM_DESTROY is a standard Windows system Message usually trapped by C apps or (it's out case) by runtimes, usually applications can react to this message. It's certanly trapped by Acu runtime in case of quit_mode -2 (I've got only practical proofs due to the message show).I think it's possible(sorry at the moment I've no code to show it) interact with system API's to reject shutting down action (maybe Gisle can jump in and light up some good ideas) but at the moment I've no idea of how do it.
Trying to do with what we have and combining manual suggestions you can try:
QUIT_MODE 100
MENU_ITEM Hot_Key ="shutdown" 100
where shutdown is a program in wich user is adviced fro a cleanup exit and try set event-action variable to event-action-fail.
Another way:
set quit_mode to -2
try trapping msg-close of main window via event-procedure
and if msg-close event is processed without a certain flag raised (of ex. by pressing a custom push button for exit) you
set event-action to event-action-fail
maybe runtime will do the job to reject WM_DESTROY for you.
hope this helps, bye Gio

Other way
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.