Jump to content

WinGetDlgMsg

From EDM2
Revision as of 18:52, 14 May 2025 by Martini (talk | contribs) (Related Functions)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function obtains a message from the application's queue associated with the specified dialog.

Syntax

WinGetDlgMsg(hwndDlg, pqmsg)

Parameters

hwndDlg (HWND) - Input
Dialog-window handle.
pqmsg (PQMSG) - Output
Message structure.

Returns

rc (BOOL) - Returns
Continue message indicator.
TRUE
Message returned is not a WM_QUIT message and the dialog has not been dismissed.
FALSE
Message returned is a WM_QUIT message or the dialog has been dismissed.

Remarks

This function enables a language that cannot support window procedures to provide the function of a modal dialog. The application creates a modeless dialog by the use of the WinCreateDlg or the WinLoadDlg functions and then issues this call to process messages only associated with the dialog.

The first time that this function is issued, the owner of the window specified by hwndDlg is disabled, thereby preventing input into windows other than the dialog. The owner of the window specified by hwndDlg is enabled when the WinDismissDlg function is issued either by the application or by the default dialog procedure.

If a WM_QUIT is encountered, WinGetDlgMsg itself issues a WinDismissDlg function, and posts the WM_QUIT message back to the queue so that the application main loop terminates in the normal way.

Errors

Possible returns from WinGetLastError:

  • PMERR_INVALID_HWND (0x1001) An invalid window handle was specified.

Example Code

#define INCL_WINDIALOGS /* Or use INCL_WIN, INCL_PM, Also in COMMON section */
#include <os2.h>

HWND     hwndDlg;  /*  Dialog-window handle. */
PQMSG    pqmsg;    /*  Message structure. */
BOOL     rc;       /*  Continue message indicator. */

rc = WinGetDlgMsg(hwndDlg, pqmsg);

This example uses WinGetDlgMsg to provide a modal dialog. When the user causes an open message (application defined IDM_OPEN), the dialog is loaded and displayed; WinGetDlgMsg then loops, grabbing messages from the queue and calling MyDlgRoutine-the dialog procedure which processes the messages-with the appropriate parameters. When the dialog issues a WM_QUIT, WinGetDlgMsg returns FALSE and the loop ends, returning control to owner window.

#define INCL_WINDIALOGS         /* Window Dialog Mgr Functions   */
#include <os2.h>

HWND   hwnd;            /* owner window                        */
HWND   hwndDlg;         /* dialog window                       */
PQMSG  pqmsgmsg;        /* message                             */

case IDM_OPEN:
    hwndDlg = WinLoadDlg(HWND_DESKTOP,  /* parent is desk top */
                         hwnd,          /* owner window handle */
                         NULL,          /* modeless dialog */
                         0L,            /* load from .EXE */
                         DLG_ID,        /* dialog resource id */
                         NULL);        /* no dialog parameters */

    /* loop and process dialog messages until WM_QUIT, calling
       dialog procedure for each message */
    while (WinGetDlgMsg(hwndDlg, &qmsg))
        MyDlgRoutine(hwndDlg, qmsg.msg, qmsg.mp1, qmsg.mp2);
    break;



MRESULT MyDlgRoutine(HWND  hwndDlg, ULONG usMsgid, MPARAM mp1,
                        MPARAM mp2)
{
switch(usMsgid)
  {
  /*
  .
  . process messages
  .
  */

  default:
      return (WinDefDlgProc(hwndDlg, usMsgid, mp1, mp2));
  }
}

Related Functions