Jump to content

WinPostQueueMsg

From EDM2

This function posts a message to a message queue.

Syntax

WinPostQueueMsg(hmq, msg, mp1, mp2)

Parameters

hmq (HMQ) - Input
Message-queue handle.
msg (ULONG) - Input
Message identifier.
mp1 (MPARAM) - Input
Parameter 1.
mp2 (MPARAM) - Input
Parameter 2.
rc (BOOL) - Returns
Success indicator. TRUE for success, FALSE for error or queue full.

Returns

rc (BOOL) - returns
Success indicator.
TRUE
Successful completion
FALSE
Error occurred, or the queue was full.

Remarks

This function can be used to post messages to any queue in the system.

It constructs a QMSG structure by setting its parameters from the corresponding parameters of this function, and by deriving its parameters from the system time and pointer position when this function was called. The QMSG structure is then placed on the specified queue.

Errors

Possible returns from WinGetLastError:

  • PMERR_INVALID_HMQ (0x1002) - An invalid message-queue handle was specified.

Example Code

#define INCL_WINMESSAGEMGR /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>

HMQ     hmq;   /* Message-queue handle. */
ULONG   msg;   /* Message identifier. */
MPARAM  mp1;   /* Parameter 1. */
MPARAM  mp2;   /* Parameter 2. */
BOOL    rc;    /* Success indicator. */

rc = WinPostQueueMsg(hmq, msg, mp1, mp2);

This example posts a Set menu item checked attribute message (MM_SETITEMATTR) to the specified message queue in response to a menu select message (WM_MENUSELECT).

#define INCL_WINMESSAGEMGR         /* Window Message Functions         */
#define INCL_WINMENUS              /* Window Menu Functions            */
#include <os2.h>

BOOL    fResult;              /* message-posted indicator             */
ULONG   ulMsgid;              /* message id                         */
HMQ     hmq;                  /* message queue handle               */
MPARAM  mp1;                  /* Parameter 1 (rectl structure)      */
MPARAM  mp2;                  /* Parameter 2 (frame boolean)        */
USHORT  usItemId;             /* menu item id                       */

case WM_MENUSELECT:
    usItemId = SHORT1FROMMP(mp1);

    /* initialize message id, parameters */
    ulMsgid = MM_SETITEMATTR;
    mp1 = MPFROM2SHORT(usItemId, TRUE);
    mp2 = MPFROM2SHORT(MIA_CHECKED, TRUE);

    fResult = WinPostQueueMsg(hmq, ulMsgid, mp1, mp2);

Related Messages

Related Functions