function MsgBox(const Text: String; const Typ: TMsgBoxType; const Buttons: Integer): Integer;
Displays a message box. Text specifies the message to display. Typ specifies which icon to display in the message box. Buttons specifies which buttons to include in the message box. Returns an ID* constant indicating the button the user clicked, or 0 if the function fails (which shouldn't happen unless an invalid parameter is specified or system resources are exhausted).
TMsgBoxType is defined as:
TMsgBoxType = (mbInformation, mbConfirmation, mbError, mbCriticalError);
Supported flags for Buttons are:
MB_OK, MB_OKCANCEL, MB_ABORTRETRYIGNORE, MB_YESNOCANCEL, MB_YESNO, MB_RETRYCANCEL, MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON3, MB_SETFOREGROUND
Possible return values are:
IDOK, IDCANCEL, IDABORT, IDRETRY, IDIGNORE, IDYES, IDNO
begin // Display a simple message box with an OK button MsgBox('Hello.', mbInformation, MB_OK); // Ask the user a Yes/No question if MsgBox('Are you sure?', mbConfirmation, MB_YESNO) = IDYES then begin // user clicked Yes end; // Ask the user a Yes/No question, defaulting to No if MsgBox('Are you sure?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2) = IDYES then begin // user clicked Yes end; end;