Share via


UI2.ShowModalDialog method (String, Object, Object, Object, Object, Object)

Displays a custom modal dialog box in a Microsoft InfoPath form.

Namespace:  Microsoft.Office.Interop.InfoPath.SemiTrust
Assembly:  Microsoft.Office.Interop.InfoPath.SemiTrust (in Microsoft.Office.Interop.InfoPath.SemiTrust.dll)

Syntax

'Declaration
Function ShowModalDialog ( _
    bstrName As String, _
    varArguments As Object, _
    varHeight As Object, _
    varWidth As Object, _
    varTop As Object, _
    varLeft As Object _
) As Object
'Usage
Dim instance As UI2
Dim bstrName As String
Dim varArguments As Object
Dim varHeight As Object
Dim varWidth As Object
Dim varTop As Object
Dim varLeft As Object
Dim returnValue As Object

returnValue = instance.ShowModalDialog(bstrName, _
    varArguments, varHeight, varWidth, _
    varTop, varLeft)
Object ShowModalDialog(
    string bstrName,
    Object varArguments,
    Object varHeight,
    Object varWidth,
    Object varTop,
    Object varLeft
)

Parameters

  • bstrName
    Type: System.String

    The name of the .html file used for the modal dialog box.

  • varArguments
    Type: System.Object

    Specifies the arguments to use when displaying the modal dialog box. Can be any type of value, including an array of values.

  • varHeight
    Type: System.Object

    Sets the height of the modal dialog box.

  • varWidth
    Type: System.Object

    Sets the width of the modal dialog box.

  • varTop
    Type: System.Object

    Sets the top position of the modal dialog box relative to the upper left corner of the desktop.

  • varLeft
    Type: System.Object

    Sets the left position of the modal dialog box relative to the upper left corner of the desktop.

Return value

Type: System.Object
An object that specifies how to display the modal dialog box.

Implements

UI.ShowModalDialog(String, Object, Object, Object, Object, Object)

Remarks

The ShowModalDialog method allows you to display custom dialog boxes to users as they fill out a fully trusted form. Custom dialog boxes are implemented as .html files created in any type of HTML editor, such as Microsoft FrontPage. You can use scripting code in a custom dialog box that interacts with the InfoPath object model if you pass objects to the custom dialog box using the varArguments parameter.

To use a custom dialog box in an InfoPath form, you must first add the .html file of the custom dialog box to the form's set of resource files by using the Resource Files dialog box. The Resource Files dialog box is available from the Tools menu in design mode. After you have added the custom dialog box file to the form, you can use the ShowModalDialog method to display it.

Although the ShowModalDialog method can only be used in fully trusted forms, you can create a custom dialog box in standard forms using the showModalDialog method of the Dynamic HTML (DHTML) object model if you have an HTML task pane specified in your form, or by using a Windows form.

Important

This member can be accessed only by forms opened from a form template that has been configured to run with full trust using the Security and Trust category of the Form Options dialog box. This member requires full trust for the immediate caller and cannot be used by partially trusted code. For more information, see "Using Libraries from Partially Trusted Code" on MSDN.

Examples

In the following example, the ShowModalDialog method of the UIObject object is used to display a custom dialog box. Note that the XDocument object is passed to the custom dialog box using the varArguments parameter.

thisXDocument.UI.ShowModalDialog("show.htm",(object)thisXDocument,100,100,10,10);

The following example is the HTML code used to implement a simple custom dialog box. Note the use of the dialogArguments property of the DHTML window object to get the values passed to the custom dialog box, which in this case is the XDocument object of the InfoPath object model, from the ShowModalDialog method. When a user clicks the Show Alert button in the custom dialog box, the source XML of the form's underlying XML document appears in a message box.

<html>
<head>
<script language="jscript">
 var gobjXDocument = null;
 function Initialize()
 {
  // Save a reference to the XDocument object.
  if (typeof window.dialogArguments == "object")
  gobjXDocument = window.dialogArguments;
 }
</script>

<title>A Simple Custom Dialog Box</title>
</head>

<body style="BACKGROUND-COLOR: window" onLoad="Initialize()">
 <strong>Click one of the following buttons:</strong>
 <br/>
 <br/>
 <div id="divButtons" tyle="align:center">
 <input id="btnShowAlert" style="WIDTH: 106px; HEIGHT: 24px" 
  onclick='gobjXDocument.UI.Alert(gobjXDocument.DOM.xml);' 
   type="button" size="21" value="Show Alert"></input>
 <input id="btnCancel" style="WIDTH: 106px; HEIGHT: 24px" 
  onclick="window.close();" type="button" size="21" 
  value="Cancel"></input>
 </div>
</body>
</html>

For information on how to use the ShowModalDialog box method, see How to: Display Alerts and Dialog Boxes Using the InfoPath 2003 Object Model.

See also

Reference

UI2 interface

UI2 members

ShowModalDialog overload

Microsoft.Office.Interop.InfoPath.SemiTrust namespace