This example, after uses WinDispatchMsg within a WinGetMsg loop to dispatch window messages to a window procedure.
#define INCL_WINMESSAGEMGR /* Window Message Functions */ #define INCL_WINWINDOWMGR /* Window Manager Functions */ #include <os2.h> HAB hab; /* anchor-block handle */ HMQ hmq; /* message queue handle */ QMSG qmsg; /* message */ hab = WinInitialize(0); /* initialize PM */ hmq = WinCreateMsgQueue(hab, 0); /* create default size queue */ /* . . initialize windows . */ /* get and dispatch messages from queue */ while (WinGetMsg(hab, &qmsg, 0, 0, 0)) WinDispatchMsg(hab, &qmsg);