This example uses WinPeekMsg to count the total number of pending messages for the window corresponding to hwndFilter.
#define INCL_WINMESSAGEMGR /* Window Message Functions */ #define INCL_WINWINDOWMGR /* Window Manager Functions */ #include <os2.h> HAB hab; /* anchor-block handle */ QMSG qmsg; /* message */ HWND hwndFilter; /* message queue filter */ ULONG flOptions; /* peek options */ ULONG ulMsgCount=0; /* message count */ /* don't remove messages */ flOptions = PM_NOREMOVE; /* count number of messages for filter window */ while (WinPeekMsg (hab, &qmsg, hwndFilter, 0, 0, flOptions)) ulMsgCount++;