WinCancelShutdown: Difference between revisions
Appearance
mNo edit summary |
|||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
This function cancels a request for an application to shut down. | This function cancels a request for an application to shut down. | ||
==Syntax== | ==Syntax== | ||
WinCancelShutdown(hmq, fCancelAlways) | WinCancelShutdown (hmq, fCancelAlways) | ||
==Parameters== | ==Parameters== | ||
;hmq (HMQ) - input | ;hmq (HMQ) - input:Handle of message queue for current thread. | ||
:Handle of message queue for current thread. | ;fCancelAlways (BOOL) - input:Cancellation control. | ||
:;TRUE:No WM_QUIT message should be placed on this queue during system shutdown. | |||
:;FALSE:The applications ignore any outstanding WM_QUIT messages already sent to it, but a message should be sent during other system shutdowns. | |||
==Returns== | ==Returns== | ||
;rc (BOOL) - returns | ;rc (BOOL) - returns:Success indicator. | ||
:Success indicator. | :;TRUE:Successful completion | ||
:;FALSE:Error occurred. | |||
:;TRUE | |||
:;FALSE | |||
==Remarks== | ==Remarks== | ||
On a system shutdown, each message queue normally posts a WM_QUIT message. An application can then handle this message in one of the three ways: | On a system shutdown, each message queue normally posts a WM_QUIT message. An application can then handle this message in one of the three ways: | ||
*Destroy its message queue using WinDestroyMsgQueue (hmq). | *Destroy its message queue using WinDestroyMsgQueue (hmq). | ||
*Call WinCancelShutdown (hmq, TRUE) to prevent the current thread's event queue from receiving the WM_QUIT messages when the system is shut down. This does not stop other threads from receiving this message. | *Call WinCancelShutdown (hmq, TRUE) to prevent the current thread's event queue from receiving the WM_QUIT messages when the system is shut down. This does not stop other threads from receiving this message. | ||
*Call WinCancelShutdown (hmq, FALSE) to remove all pending WM_QUIT messages from the current thread's event queue but allow future WM_QUIT messages to be posted. | *Call WinCancelShutdown (hmq, FALSE) to remove all pending WM_QUIT messages from the current thread's event queue but allow future WM_QUIT messages to be posted. | ||
Either way, the system can proceed to the next queue. | Either way, the system can proceed to the next queue. | ||
==Example Code== | ==Example Code== | ||
Line 41: | Line 33: | ||
rc = WinCancelShutdown(hmq, fCancelAlways); | rc = WinCancelShutdown(hmq, fCancelAlways); | ||
</pre> | </pre> | ||
This example cancels a shutdown request (WM_QUIT message) and specifies that the message queue will not accept any new WM_QUIT messages. | |||
This example cancels a shutdown request (WM_QUIT message) and specifies that the message queue will not accept any new WM_QUIT messages. | |||
<pre> | <pre> | ||
#define INCL_WINMESSAGEMGR /* Window Message Functions */ | #define INCL_WINMESSAGEMGR /* Window Message Functions */ | ||
Line 56: | Line 47: | ||
==Related Functions== | ==Related Functions== | ||
*[[WinCreateMsgQueue]] | *[[WinCreateMsgQueue]] | ||
*[[WinInitialize]] | *[[WinInitialize]] | ||
Line 63: | Line 53: | ||
==Related Messages== | ==Related Messages== | ||
*[[WM_QUIT]] | *[[WM_QUIT]] | ||
[[Category:Win]] | [[Category:Win]] |
Latest revision as of 14:59, 13 May 2022
This function cancels a request for an application to shut down.
Syntax
WinCancelShutdown (hmq, fCancelAlways)
Parameters
- hmq (HMQ) - input
- Handle of message queue for current thread.
- fCancelAlways (BOOL) - input
- Cancellation control.
- TRUE
- No WM_QUIT message should be placed on this queue during system shutdown.
- FALSE
- The applications ignore any outstanding WM_QUIT messages already sent to it, but a message should be sent during other system shutdowns.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE
- Successful completion
- FALSE
- Error occurred.
Remarks
On a system shutdown, each message queue normally posts a WM_QUIT message. An application can then handle this message in one of the three ways:
- Destroy its message queue using WinDestroyMsgQueue (hmq).
- Call WinCancelShutdown (hmq, TRUE) to prevent the current thread's event queue from receiving the WM_QUIT messages when the system is shut down. This does not stop other threads from receiving this message.
- Call WinCancelShutdown (hmq, FALSE) to remove all pending WM_QUIT messages from the current thread's event queue but allow future WM_QUIT messages to be posted.
Either way, the system can proceed to the next queue.
Example Code
#define INCL_WINMESSAGEMGR /* Or use INCL_WIN, INCL_PM, Also in COMMON section */ #include <os2.h> HMQ hmq; /* Handle of message queue for current thread. */ BOOL fCancelAlways; /* Cancellation control. */ BOOL rc; /* Success indicator. */ rc = WinCancelShutdown(hmq, fCancelAlways);
This example cancels a shutdown request (WM_QUIT message) and specifies that the message queue will not accept any new WM_QUIT messages.
#define INCL_WINMESSAGEMGR /* Window Message Functions */ #include <os2.h> HAB hab, BOOL fSuccess; /* Success indicator */ HMQ hmq; /* Queue handle */ hmq = WinCreateMsgQueue(hab, 0); fSuccess = WinCancelShutdown(hmq, TRUE);