WinMessageBox2 creates a message window that can be used to display error messages and ask questions. It is a more powerful version of WinMessageBox, including options for non-modality and customization of buttons with text and icons or mini-icons. Buttons included in the enhanced message box are specified in the button definition array MB2D, where custom text can be added.
To support the use of the MB_NONMODAL style, two notification messages are used:
WM_MSGBOXINIT
The following example uses WinMessageBox2 to create a message box containing a customized icon:
#define INCL_WINDIALOGS /* Window Dialog Manager Functions */#define INCL_WINPOINTERS /* Window Pointer Functions */
#include <os2.h>
#include <stdio.h>
#include <string.h>
CHAR szMsg[100]; /* Message
HWND hwndClient; /* Client-window handle */
MB2INFO mb2info; /* Message Box input structure */
MB2D mb2d[4] = { /* Array of button definitions*/
{ "AAAA", ID_BUTTON1, BS_DEFAULT},
{ "BBBB", ID_BUTTON2, 0},
{ "CCCC", ID_BUTTON3, 0},
{ "DDDD", ID_BUTTON4, 0}
};
mb2info.hIcon = WinLoadPointer(HWND_DESKTOP, 0, ID_ICON1);
mb2info.cButtons = 4; /* Number of buttons */
mb2info.flStyle = MB_CUSTOMICON | MB_MOVEABLE;
/* Icon style flags */
mb2info.hwndNotify = NULLHANDLE; /* Reserved */
mb2info.cb = sizeof(MB2INFO) + ((mb2info.cButons >1) ?
(mb2info.cButtons -1) * sizeof (MB2D) : 0);
memcpy (&mb2info.mb2d, &mb2d, mb2info.cb);
mb2info.pmb2d = mb2d; /* Array of button definitions*/
sprintf (&szMsg, %s, "Error condition exists");
WinMessageBox2(HWND_DESKTOP,
hwndClient, /* Client-window handle */
&szMsg, /* Body of the message
"Debugging Information",
/* Title of the message */
0, /* Message Box id */
&mb2info); /* Message Box input structure