편집

다음을 통해 공유


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

Definition

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

public object ShowModalDialog (string bstrName, object varArguments, object varHeight, object varWidth, object varTop, object varLeft);
abstract member ShowModalDialog : string * obj * obj * obj * obj * obj -> obj
Public Function ShowModalDialog (bstrName As String, Optional varArguments As Object, Optional varHeight As Object, Optional varWidth As Object, Optional varTop As Object, Optional varLeft As Object) As Object

Parameters

bstrName
String

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

varArguments
Object

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

varHeight
Object

Sets the height of the modal dialog box.

varWidth
Object

Sets the width of the modal dialog box.

varTop
Object

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

varLeft
Object

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

Returns

An object that specifies how to display the modal dialog box.

Implements

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.<span class="label">ShowModalDialog</span>("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.

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

&lt;title&gt;A Simple Custom Dialog Box&lt;/title&gt;
&lt;/head&gt;

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

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

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.

Applies to