Creates, displays, and operates a message box. The message box contains application-defined message text and title, any icon, and any combination of predefined push buttons.
MessageBoxEx(cText [, nFlags [, cCaption [, nHwnd [, cnIconResource [, nHInstance [, nHelpContextId [, nLanguageId]]]]]]])
Parameters
- cText
Specifies the text that appears in the dialog box.
Note
The VFP MESSAGEBOX( ) function allows to pass an expression of any type in this parameter - this function does NOT!
The value passed has to be a string, just use TRANSFORM( ) or other formatting functions to create a string out of an expression.
- nFlags (optional)
default = 0
The nFlags parameter controls the appearance and behaviour of the message box.
Buttons. Value Description MB_OK OK button only MB_OKCANCEL OK and Cancel buttons MB_ABORTRETRYIGNORE Abort, Retry, and Ignore buttons MB_YESNOCANCEL Yes, No, and Cancel buttons MB_YESNO Yes and No buttons MB_RETRYCANCEL Retry and Cancel buttons Icon Value Description MB_ICONSTOP OK button only MB_ICONQUESTION OK and Cancel buttons MB_ICONEXCLAMATION Abort, Retry, and Ignore buttons MB_ICONINFORMATION Yes, No, and Cancel buttons Default button. Value Description MB_DEFBUTTON1 The first button is the default button.
MB_DEFBUTTON1 is the default unless MB_DEFBUTTON2, MB_DEFBUTTON3, or MB_DEFBUTTON4 is specified.MB_DEFBUTTON2 Second button is default. MB_DEFBUTTON3 Third button is default. MB_DEFBUTTON4 The fourth button is the default button. Modality of the dialog box. Value Description MB_APPLMODAL The user must respond to the message box before continuing work in the window identified by the nWnd parameter. However, the user can move to the windows of other threads and work in those windows.
Depending on the hierarchy of windows in the application, the user may be able to move to other windows within the thread. All child windows of the parent of the message box are automatically disabled, but pop-up windows are not.
MB_APPLMODAL is the default if neither MB_SYSTEMMODAL nor MB_TASKMODAL is specified.MB_SYSTEMMODAL Same as MB_APPLMODAL except that the message box has the WS_EX_TOPMOST style. Use system-modal message boxes to notify the user of serious, potentially damaging errors that require immediate attention (for example, running out of memory). This flag has no effect on the user's ability to interact with windows other than those associated with nHwnd. MB_TASKMODAL Same as MB_APPLMODAL except that all the top-level windows belonging to the current thread are disabled if the nWnd parameter is 0. Use this flag when the calling application or library does not have a window handle available but still needs to prevent input to other windows in the calling thread without suspending other threads. Various other options. Value Description MB_DEFAULT_DESKTOP_ONLY Same as desktop of the interactive window station. For more information, see Window Stations.
If the current input desktop is not the default desktop, MessageBox does not return until the user switches to the default desktop.MB_RIGHT The text is right-justified. MB_RTLREADIND Displays message and caption text using right-to-left reading order on Hebrew and Arabic systems. MB_SETFOREGROUND The message box becomes the foreground window. Internally, the system calls the SetForegroundWindow function for the message box. MB_TOPMOST The message box is created with the WS_EX_TOPMOST window style. MB_SERVICE_NOTIFICATION The caller is a service notifying the user of an event. The function displays a message box on the current active desktop, even if there is no user logged on to the computer. Terminal Services: If the calling thread has an impersonation token, the function directs the message box to the session specified in the impersonation token. If this flag is set, the nWnd parameter must be 0. This is so that the message box can appear on a desktop other than the desktop corresponding to the nWnd.
For information on security considerations in regard to using this flag, see Interactive Services. In particular, be aware that this flag can produce interactive content on a locked desktop and should therefore be used for only a very limited set of scenarios, such as resource exhaustion.
- cCaption (optional)
default = NULL
The message box title. If this member is NULL, the default title "Error" is used.
- nHwnd (optional)
default = NULL
A handle to the owner window.
If nHwnd is NULL or omitted the current active window is set as the owner window.
You can also specify 0 if the dialog box should not have an owner window.
- cnIconResource (optional)
default = NULL
Identifies a custom icon resource.
This parameter can be either a string or an integer resource identifier.
To load one of the standard system-defined icons pass NULL in the nHInstance parameter and specify one of the values listed with the LoadIcon function.
- nHInstance (optional)
default = NULL | HINSTANCE of the current executable
A handle to the module that contains the icon resource identified by the cnIconResource parameter.
If you omit this parameter parameter or pass NULL but specify a custom icon in the cnIconResource parameter
nHInstance defaults to the HINSTANCE of the current executable.
Note
The HINSTACE/HMODULE of a module (dll) can be retrieved with the GetModuleHandle or LoadLibray function.
- nHelpContextId (optional)
default = 0
Identifies a help context.
If a help event occurs, this value is passed to the owner window.
- nLanguageId (optional)
default = GetUserDefaultUILanguage()
The language in which to display the text contained in the predefined push buttons.
For a list of supported language identifiers, see Language Identifiers. Note that each localized release of Windows typically contains resources only for a limited set of languages. Thus, for example, the U.S. version offers LANG_ENGLISH, the French version offers LANG_FRENCH, the German version offers LANG_GERMAN, and the Japanese version offers LANG_JAPANESE. Each version offers LANG_NEUTRAL. This limits the set of values that can be used with the nLanguageId parameter. Before specifying a language identifier, you should enumerate the locales that are installed on a system.
Return Value
If the function succeeds, the return value is one of the following menu-item values.
If a message box has a Cancel button, the function returns the IDCANCEL value if either the ESC key is pressed or the Cancel button is selected. If the message box has no Cancel button, pressing ESC has no effect.
If there is not enough memory to create the message box, error 43 is raised.
Value | Description |
---|---|
IDOK | The OK button was selected. |
IDCANCEL | The Cancel button was selected. |
IDABORT | The Abort button was selected. |
IDRETRY | The Retry button was selected. |
IDIGNORE | The Ignore button was selected. |
IDYES | The Yes button was selected. |
IDNO | The No button was selected. |
IDTRYAGAIN | The Try Again button was selected. |
IDCONTINUE | The Continue button was selected. |
See Also
Reference
GetOpenFileName
GetSaveFileName
SHBrowseFolder