Applies to TestComplete 12.30, last modified on April 18, 2017

Description

The MessageDlg function displays a dialog box with the specified message and buttons.

Declaration

BuiltIn.MessageDlg(Param1Param2Param3Param4)

Param1 [in]    Required    String    
Param2 [in]    Required    Integer    
Param3 [in]    Required    Byte    
Param4 [in]    Required    Integer    
Result Integer

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Param1

The message to be displayed.

Param2

Indicates the message box type. It can be any of the following constants:

Constant Description
mtWarning The message box will contain the exclamation point icon.
mtError The message box will contain the red stop icon.
mtInformation The message box will contain the information icon.
mtConfirmation The message box will contain the question mark icon.
mtCustom The message box will not contain any bitmap.

Param3

Specifies the buttons to be displayed in the message box. This parameter can be any combination of the following values:

Constant Description Constant Description
mbYes "Yes" button mbAll "All" button
mbNo "No" button mbYesToAll "Yes to All" button
mbOK "OK" button mbNoToAll "No to All" button
mbCancel "Cancel" button mbHelp "Help" button
mbAbort "Ignore" button mbYesNoCancel "Yes", "No" and "Cancel" buttons
mbRetry "Retry" button mbOKCancel "OK" and "Cancel" buttons
mbIgnore "Ignore" button mbAbortRetryIgnore "Abort", "Retry" and "Ignore" buttons

To specify the Param3 parameter, you should create a set value using the MkSet function (see the example below). Use of MkSet is obligatory. You are not allowed to skip it.

Param4

This parameter is reserved.

Result Value

The MessageDlg function returns one of the constants that indicates which button the user pressed in the message box:

mrYes mrAll mrYesToAll
mrNo mrAbort mrNoToAll
mrOK mrRetry  
mrCancel mrIgnore  

Example

The following code demonstrates calling the MessageDlg function in scripts:

JavaScript, JScript

function TestDialog()
{
  var i;
  i = MkSet(mbYes, mbYesToAll, mbNo, mbCancel);
  i = MessageDlg("Message text", mtConfirmation, i, 0);
}

Python

def TestDialog():
  i = MkSet(mbYes, mbYesToAll, mbNo, mbCancel)
  i = MessageDlg("Message text", mtConfirmation, i, 0)

VBScript

Sub TestDialog
  i = MkSet(mbYes, mbYesToAll, mbNo, mbCancel)
  i = MessageDlg("Message text", mtConfirmation, i, 0)
End Sub

DelphiScript

procedure TestDialog;
var
  i : OleVariant;
begin
  i := MkSet(mbYes, mbYesToAll, mbNo, mbCancel);
  i := MessageDlg('Message text', mtConfirmation, i, 0);
end;

C++Script, C#Script

function TestDialog()
{
  var i;
  i = MkSet(mbYes, mbYesToAll, mbNo, mbCancel);
  i = MessageDlg("Message text", mtConfirmation, i, 0);
}

See Also

InputBox Method
InputQuery Method
ShowMessage Method
MkSet Function