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

TApplication.MessageBox

Display an message dialog with several response buttons.

Declaration

Source position: forms.pp line 1474

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 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 Dialogs.

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

  

Message Dialog

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;
The latest version of this document can be found at lazarus-ccr.sourceforge.net.