home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cenvi23.zip / MSGBOX.LIB < prev    next >
Text File  |  1995-03-28  |  4KB  |  68 lines

  1. // MsgBox.lib - Cmm code wrapper for the WinMessageBox function.  This library
  2. // ver.1        can be included in your source file to provide access to
  3. //              to the PM WinMessageBox() function.  The PM MessageBox()
  4. //              function takes a parent window handle as the first parameter,
  5. //              but this wrapper simplifies it by automatically selecting
  6. //              DSKTOP as the parent window, which is OK for a modal function.
  7. //
  8. // FUNCTION: MessageBox()
  9. // SYNTAX: MessageBox(MessageText[,BoxTitle[,TypeFlags]])
  10. //   MessageText: Text string to display in the message box.
  11. //   BoxTitle: Title to display on the box.  If NULL or this parameter is
  12. //             not supplied then Windows defaults to the string "Error"
  13. //   TypeFlags: a number of flags, or'ed together to specify the behavior
  14. //              of the message box.  If this parameter is not supplied then
  15. //              it defaults to MB_OK | MB_NOICON | MB_DEFBUTTON1 | MB_APPLMODAL.
  16. //              Possible OR'ed flags are:
  17. //       One of the following from the Button group:
  18.             #define MB_OK           0x0000   // 1 button: OK.
  19.             #define MB_OKCANCEL     0x0001   // 2 buttons OK and Cancel.
  20.             #define MB_RETRYCANCEL  0x0002   // 2 button: Retry and Cancel
  21.             #define MB_ABORTRETRYIGNORE 0x0003 // 3 butt: Abort, Retry, and Ignore
  22.             #define MB_YESNO        0x0004   // 2 button: Yes and No
  23.             #define MB_YESNOCANCEL  0x0005   // 3 button: Yes, No, and Cancel
  24.             #define MB_CANCEL       0x0006   // 1 button: Cancel
  25.             #define MB_ENTER        0x0007   // 1 button: Enter
  26.             #define MB_ENTERCANCEL  0x0008   // 2 button: Enter and Cancel
  27. //       Help button, not explicitly supported by CEnvi2
  28.             #define MB_HELP         0x2000
  29. //       One of the color or ICON group:
  30.             #define MB_NOICON       0x0000   // no icon
  31.             #define MB_ICONQUESTION 0x0010   // question mark icon
  32.             #define MB_WARNING      0x0020   // black '!' in square box
  33.             #define MB_ICONASTERISK 0x0030   // asterisk icon
  34.             #define MB_ERROR        0x0040   // STOP sign
  35. //       One of the following default actions
  36.             #define MB_DEFBUTTON1   0x0000
  37.             #define MB_DEFBUTTON2   0x0100
  38.             #define MB_DEFBUTTON3   0x0200
  39. //       One of the following MODALITY flags:
  40.             #define MB_APPLMODAL    0x0000   // CEnvi2 is disabled
  41.             #define MB_SYSTEMMODAL  0x1000   // system is disabled for this message
  42. //       Optional mobility flag
  43.             #define MB_MOVEABLE     0x4000   // message box may be moved
  44. // RETURN:   Returns one of these values:
  45.             #define MBID_OK         1        // OK pushbutton was selected
  46.             #define MBID_CANCEL     2        // CANCEL pushbutton was selected
  47.             #define MBID_ABORT      3        // ABORT pushbutton was selected
  48.             #define MBID_RETRY      4        // RETRY pushbutton was selected
  49.             #define MBID_IGNORE     5        // IGNORE pushbutton was selected
  50.             #define MBID_YES        6        // YES pushbutton was selected
  51.             #define MBID_NO         7        // NO pushbutton was selected
  52.             #define MBID_ENTER      9        // ENTER pushbutton was selected
  53.             #define MBID_ERROR      0xffff   // Function not successful; an error occurred.
  54.  
  55.  
  56. MessageBox(MessageText,BoxTitle,TypeFlags)
  57. {
  58.    #define HWND_DESKTOP    1
  59.    #define ORD_WIN32MESSAGEBOX   789
  60.    // BoxTitle and TypeFlags are optional, and so check for their existence
  61.    // or else take defaults
  62.    return PMDynamicLink("PMWIN",ORD_WIN32MESSAGEBOX,BIT32,CDECL,
  63.                         HWND_DESKTOP,PMInfo().WinHandle,MessageText,
  64.                         va_arg() < 2 ? NULL : BoxTitle,
  65.                         0,va_arg() < 3 ? MB_OK | MB_NOICON | MB_DEFBUTTON1 | MB_APPLMODAL : TypeFlags);
  66. }
  67.  
  68.