message_box
| Platform: | WINDOWS ONLY: for a cross-platform version, see IupMessage(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Definition: |
requires(WINDOWS) -- (or explicit test around calls as below) include msgbox.e if platform()=WINDOWS then -- (if requires(WINDOWS) is not being used) integer i = message_box(string msg, string title, integer style=MB_OK, atom hWnd=mWnd) else -- something else... end if |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description: |
Display a window with the specified message and title.
The style parameter determines the combination of buttons that are available for the user to press, plus some other characteristics, as detailed below. The hWnd parameter allows you to specify the owning window, see notes below. A return value of 0 indicates a failure to set up the window, otherwise one of the values listed below is returned. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pwa/p2js: | Not supported | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comments: |
Only works on Microsoft Windows, for other operating systems and cross-platform capability use something like
IupMessage (which also works fine on Windows).
Earlier versions allowed style to be a sequence - for legacy code wrap such in or_all(). Previous versions of this routine used a hWnd obtained from the C function GetActiveWindow, which could cause all manner of rude and and nasty behaviour, including disabling Task Manager, at least according to Raymond Chen, who knows far more than anyone else on the planet about such things. You can use procedure set_mb_hwnd(atom hWnd) to set a default for all future calls to message_box(). There is little or no excuse for being unable to provide a better and more sensible value, however if hWnd is NULL (the default), then MB_TASKMODAL is applied automatically (suspends all top-level windows associated with the current thread). The following constants should be used for style: To indicate the buttons displayed in the message box, specify one of the following values [optionally plus MB_HELP].  
  To display an icon in the message box, specify one of the following values. Note that MB_ICONQUESTION is no longer recommended as it is ambiguous with respect to question vs. help, and should therefore be avoided.  
  To specify the default button, (ie the one that gets initial focus and is selected by Return) specify one of the following values.  
  To indicate the modality of the dialog box, specify one of the following values.  
  To specify other options, use one or more of the following values.  
Possible values returned by message_box() (0 means failure):  
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Example: |
set_mb_hwnd(getHwnd(main)) -- (or 4th param on each call)
integer response = message_box("Do you wish to proceed?",
"My Application",
MB_YESNOCANCEL)
if response=IDCANCEL or response=IDNO then
abort(1)
end if
For a complete runnable program, see demo\Hello.exw |