Window Object

Microsoft Office InfoPath

Show All Show All

Window Object

Windows Window

Represents a window that is used in the Microsoft Office InfoPath 2003 application. Window objects represent the two types of windows that are used in the InfoPath application: the editing window that is used as the form area when a user fills out a form, and the designing window that is used as the design mode when a user designs a form.

Remarks

The Window object provides a number of properties and methods that can be used to programmatically interact with InfoPath windows, including the ability to activate or close a window and the ability to interact with the task panes and command bars that they contain. The Window object also provides a property for accessing the form's underlying XML document that is associated with the window.

Note  Some properties of the Window object are only available when using the editing window type; they will return an error if used with the designing window type.

Using the Window object

The Window objects of an InfoPath form are accessed through the Item property of the Windows collection. The type of window can be determined by the Type property of the Window object.

You can access the currently open window directly by using the ActiveWindow property of the Application object, without going through the Windows collection. You can also access the Window object that is associated with a view by using the Window property of the View object.

In the following example, implemented as an OnClick event handler for a button control, the ActiveWindow property is used to set a reference to the current window. Then the code checks the window type; if it is the editing window type, it displays the number of task panes contained in the window in a message box.

    function WindowObject::OnClick(eventObj)
{

   var objWindow;
   
   // Set a reference to the current window.
   objWindow = Application.ActiveWindow;
	
   // Check that the window is an editing window type.
   if (objWindow.Type == 0)
   {
      // Display the number of task panes in the window.
      XDocument.UI.Alert("Number of task panes: " + 
         objWindow.TaskPanes.Count);
   }
	
   objWindow = null;
}
  

For more information about using the Window object, see Working with form windows.