The following example uses WinMessageBox2 to create a message box containing a customized icon.
#define INCL_WINDIALOGS /* Window Dialog Mgr functions*/ #define INCL_WINPOINTERS /* Window Pointer functions */ #define NUM_BUT 4 #include <os2.h> ULONG ulResult; /* Indicates which button to */ /* push on the message box */ ULONG i; /* A loop index */ MB2INFO *pmbInfo; /* Pointer to the message box */ /* structure */ PSZ pszBoxTitle = "A title with up to 40 characters in it "; MB2D mb2dBut[NUM_BUT] = { /* Static copy of button definitions */ { "AAAA", ID_BUTTON1, BS_PUSHBUTTON}, /* Or use 0 */ { "BBBBBBBBBBBBBBBBB", ID_BUTTON2, BS_DEFAULT}, { "CCCCCCCC", ID_BUTTON3, 0}, { "D", ID_BUTTON4, 0} }; /* Size of the message box structure needed. */ /* Need space for MB2INFO plus 3 additional buttons */ /* (one button is defined in the MB2INFO structure). */ ULONG ulInfoSize = (sizeof(MB2INFO) + (sizeof(MB2D) * (NUM_BUT-1))); /* Allocate space for the MB2INFO structure */ pmbInfo = malloc (ulInfoSize); pmbInfo->cb = ulInfoSize; /* Size of block */ pmbInfo->hIcon = WinLoadPointer(HWND_DESKTOP, 0, ID_ICON1); pmbInfo->cButtons = NUM_BUT; /* Number of buttons for box */ pmbInfo->flStyle = MB_CUSTOMICON | MB_MOVEABLE; pmbInfo->hwndNotify = NULLHANDLE; /* Copy information for each button to the MB2INFO structure */ for (i = 0; i < NUM_BUT; i++) { memcpy( pmbInfo->mb2d+i , mb2dBut+i , sizeof(MB2D)); }; ulResult = WinMessageBox2(HWND_DESKTOP, /* Parent window */ HWND_DESKTOP, /* Owner window */ (PSZ)"Line 1 of your message.\nLine 2 of message.", pszBoxTitle, /* Message box title */ 1234L, /* Identifier for message box */ pmbInfo); /* Button definitions for */ /* message box */