[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Forms' (#lcl)

# TApplication.MessageBox

Display an message dialog with response buttons.

## Declaration

Source position: forms.pp line 1625

`public function TApplication.MessageBox(`
`Text: PChar;`
`Caption: PChar;`
`Flags: LongInt = MB_OK`
`):Integer;`

## Arguments

`Text` |  | The text in the MessageBox.
`Caption` |  | The Caption of the MessageBox.
`Flags` |  | The icon and buttons appearing in the message box.

## Function result

Can be one of the following values:

- IDOK
- IDCANCEL
- IDABORT
- IDRETRY
- IDIGNORE
- IDYES
- IDNO
- IDCLOSE
- IDHELP

## Description

The function is used internally to display messages during the handling of Exceptions, but is also available to application programmers as an alternative to some of the message dialogs found in the Dialogs unit.

The function returns an integer value corresponding to the button that was pressed; its value can be determined by reference to the constants [IDOK..IDHELP].

## See also

MessageDlg |  | Shows a message to the user and gets the response.

## Example

     Uses Forms, Dialogs, LCLType;

     Procedure DisplayMessageBox;
       var reply, boxstyle: integer;
       begin
         with application do begin
           boxstyle :=  MB_ICONQUESTION + MB_YESNO;
           reply :=  MessageBox ('Press either button', 'MessageBoxDemo', boxstyle);
           if reply = IDYES then MessageBox ('Yes       ', 'Reply',MB_ICONINFORMATION)
           else MessageBox ('No         ', 'Reply', MB_ICONHAND)
       end;