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)); } }