This example shows a typical use of the WinMessageBox function when debugging an application. The C run-time function sprintf is used to format the body of the message. In this case, it converts the coordinates of the mouse pointer (retrieved with the WinQueryPointerPos function) into a string. The string is then displayed by calling WinMessageBox.
#define INCL_WINDIALOGS /* Window Dialog Mgr Functions */ #define INCL_WINPOINTERS /* Window Pointer Functions */ #include <os2.h> CHAR szMsg[100]; /* message */ POINTL ptl; /* message data */ HWND hwndClient; /* client window handle */ WinQueryPointerPos(HWND_DESKTOP, &ptl); sprintf(szMsg, "x = ld y = ld", ptl.x, ptl.y); WinMessageBox(HWND_DESKTOP, hwndClient, /* client-window handle */ szMsg, /* body of the message */ "Debugging information", /* title of the message */ 0, /* message box id */ MB_NOICON | MB_OK); /* icon and button flags */