Vcl.Forms.TApplication.MessageBox

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function MessageBox(const Text, Caption: PChar; Flags: Longint = MB_OK): Integer;

C++

int __fastcall MessageBox(const System::WideChar * Text, const System::WideChar * Caption, System::LongInt Flags = 0x0);

Properties

Type Visibility Source Unit Parent
function public
Vcl.Forms.pas
Vcl.Forms.hpp
Vcl.Forms TApplication

Description

Displays a specified message to the user.

Use MessageBox to display a generic dialog box containing a message and one or more buttons. The Caption parameter specifies the caption of the dialog box and is optional.

MessageBox is an encapsulation of the Windows API MessageBox function, which is described at http://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx.

The TApplication encapsulation of MessageBox automatically supplies the missing window handle parameter needed for the Windows API function.

The value of the Text parameter is the message, which can be longer than 255 characters if necessary. Long messages are automatically wrapped in the message box.

The value of the Caption parameter is the caption that appears in the title bar of the dialog box. Captions can be longer than 255 characters, but do not wrap. A long caption results in a wide message box.

The Flags parameter specifies what buttons appear on the message box and the behavior (possible return values). The following table lists the possible values. These values can be combined to obtain the desired effect.


Value Meaning

MB_ABORTRETRYIGNORE

The message box contains three push buttons: Abort, Retry, and Ignore.

MB_OK

The message box contains one push button: OK. This is the default.

MB_OKCANCEL

The message box contains two push buttons: OK and Cancel.

MB_RETRYCANCEL

The message box contains two push buttons: Retry and Cancel.

MB_YESNO

The message box contains two push buttons: Yes and No.

MB_YESNOCANCEL

The message box contains three push buttons: Yes, No, and Cancel.


MessageBox returns 0 if there is not enough memory to create the message box. Otherwise it returns one of the following values:


Value Numeric Value Meaning

IDOK

1

The user chose the OK button.

IDCANCEL

2

The user chose the Cancel button.

IDABORT

3

The user chose the Abort button.

IDRETRY

4

The user chose the Retry button.

IDIGNORE

5

The user chose the Ignore button.

IDYES

6

The user chose the Yes button.

IDNO

7

The user chose the No button.


See Also

Code Examples