WinBroadcastMsg: Difference between revisions
Appearance
Created page with "This function broadcasts a message to multiple windows. ==Syntax== WinBroadcastMsg(hwndParent, ulMsgId, mpParam1, mpParam2, flCmd); ==Parameters== ;hwndParent (HWND) - inp..." |
mNo edit summary |
||
Line 1: | Line 1: | ||
This function broadcasts a message to multiple windows. | This function broadcasts a message to multiple windows. | ||
==Syntax== | ==Syntax== | ||
WinBroadcastMsg(hwndParent, ulMsgId, mpParam1, mpParam2, flCmd) | WinBroadcastMsg(hwndParent, ulMsgId, mpParam1, mpParam2, flCmd) | ||
==Parameters== | ==Parameters== | ||
;hwndParent (HWND) - input | ;hwndParent (HWND) - input:Parent-window handle. | ||
:Parent-window handle. | ;ulMsgId (ULONG) - input:Message identifier. | ||
;mpParam1 (MPARAM) - input:Parameter 1. | |||
;ulMsgId (ULONG) - input | ;mpParam2 (MPARAM) - input:Parameter 2. | ||
:Message identifier. | ;flCmd (ULONG) - input:Broadcast message command. | ||
::BMSG_POST : Post the message. This value is mutually exclusive with BMSG_SEND and BMSG_POSTQUEUE. | |||
;mpParam1 (MPARAM) - input | ::BMSG_SEND : Send the message. This value is mutually exclusive with BMSG_POST and BMSG_POSTQUEUE. | ||
:Parameter 1. | ::BMSG_POSTQUEUE : Post a message to all threads that have a message queue. This value is mutually exclusive with BMSG_POST and BMSG_SEND. The hwnd parameter of the QMSG structure is set to NULL. | ||
::BMSG_DESCENDANTS : Broadcast the message to all the descendants of the hwndParent parameter. | |||
;mpParam2 (MPARAM) - input | ::BMSG_FRAMEONLY : Broadcast the message only to windows with a style of CS_FRAME. | ||
:Parameter 2. | |||
;flCmd (ULONG) - input | |||
:Broadcast message command. | |||
: | |||
: | |||
: | |||
: | |||
: | |||
==Returns== | ==Returns== | ||
;rc (BOOL) - returns | ;rc (BOOL) - returns:Success indicator. | ||
:Success indicator. | ::TRUE : Message was sent or posted successfully to all applicable windows | ||
::FALSE : Error occurred. | |||
:Message was sent or posted successfully to all applicable windows | |||
:Error occurred. | |||
==Remarks== | ==Remarks== | ||
This function sends or posts a message to all the immediate child windows of hwndParent, except in the case when flCmd is BMSG_DESCENDANTS. | This function sends or posts a message to all the immediate child windows of hwndParent, except in the case when flCmd is BMSG_DESCENDANTS. | ||
The ulMsgId, mpParam1, and mpParam2 parameters make up the message sent or posted. The window handle of the receiving window is added to the message. | The ulMsgId, mpParam1, and mpParam2 parameters make up the message sent or posted. The window handle of the receiving window is added to the message. | ||
==Example Code== | ==Example Code== | ||
This example broadcasts a WM_CLOSE message to all descendants of the specified window. | This example broadcasts a WM_CLOSE message to all descendants of the specified window. | ||
<pre> | <pre> | ||
#define INCL_WINMESSAGEMGR /* Window Message Functions */ | #define INCL_WINMESSAGEMGR /* Window Message Functions */ | ||
Line 66: | Line 47: | ||
flCmd = BMSG_DESCENDANTS; | flCmd = BMSG_DESCENDANTS; | ||
fSuccess = WinBroadcastMsg(hwndParent, ulMsgId, | fSuccess = WinBroadcastMsg(hwndParent, ulMsgId, mpParam1, mpParam2, flCmd); | ||
</pre> | </pre> | ||
==Related Functions== | ==Related Functions== | ||
* WinCreateMsgQueue | * WinCreateMsgQueue | ||
* WinDestroyMsgQueue | * WinDestroyMsgQueue |
Latest revision as of 23:46, 20 November 2023
This function broadcasts a message to multiple windows.
Syntax
WinBroadcastMsg(hwndParent, ulMsgId, mpParam1, mpParam2, flCmd)
Parameters
- hwndParent (HWND) - input
- Parent-window handle.
- ulMsgId (ULONG) - input
- Message identifier.
- mpParam1 (MPARAM) - input
- Parameter 1.
- mpParam2 (MPARAM) - input
- Parameter 2.
- flCmd (ULONG) - input
- Broadcast message command.
- BMSG_POST : Post the message. This value is mutually exclusive with BMSG_SEND and BMSG_POSTQUEUE.
- BMSG_SEND : Send the message. This value is mutually exclusive with BMSG_POST and BMSG_POSTQUEUE.
- BMSG_POSTQUEUE : Post a message to all threads that have a message queue. This value is mutually exclusive with BMSG_POST and BMSG_SEND. The hwnd parameter of the QMSG structure is set to NULL.
- BMSG_DESCENDANTS : Broadcast the message to all the descendants of the hwndParent parameter.
- BMSG_FRAMEONLY : Broadcast the message only to windows with a style of CS_FRAME.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE : Message was sent or posted successfully to all applicable windows
- FALSE : Error occurred.
Remarks
This function sends or posts a message to all the immediate child windows of hwndParent, except in the case when flCmd is BMSG_DESCENDANTS.
The ulMsgId, mpParam1, and mpParam2 parameters make up the message sent or posted. The window handle of the receiving window is added to the message.
Example Code
This example broadcasts a WM_CLOSE message to all descendants of the specified window.
#define INCL_WINMESSAGEMGR /* Window Message Functions */ #include <os2.h> BOOL fSuccess; /* Success indicator */ HWND hwndParent; /* parent window handle */ ULONG ulMsgId; /* Message identifier */ MPARAM mpParam1; /* Parameter 1 */ MPARAM mpParam2; /* Parameter 2 */ ULONG flCmd; /* message command */ /* set msg to close window, parameters to NULL */ ulMsgId = WM_CLOSE; mpParam1 = MPVOID; mpParam2 = MPVOID; /* broadcast to all descendants */ flCmd = BMSG_DESCENDANTS; fSuccess = WinBroadcastMsg(hwndParent, ulMsgId, mpParam1, mpParam2, flCmd);
Related Functions
- WinCreateMsgQueue
- WinDestroyMsgQueue
- WinDispatchMsg
- WinGetDlgMsg
- WinGetMsg
- WinInSendMsg
- WinPeekMsg
- WinPostMsg
- WinPostQueueMsg
- WinQueryMsgPos
- WinQueryMsgTime
- WinQueryQueueInfo
- WinQueryQueueStatus
- WinSendDlgItemMsg
- WinSendMsg
- WinSetClassMsgInterest
- WinSetMsgInterest
- WinSetMsgMode
- WinSetSynchroMode
- WinWaitMsg