Edit

Share via


Window Class

Definition

Represents a window that is used in the Microsoft InfoPath application.

public ref class Window abstract
public abstract class Window
type Window = class
Public MustInherit Class Window
Inheritance
Window

Examples

In the following example, 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.

// Set a reference to the current window.
Window currentWindow = this.Application.ActiveWindow;

// Check if the window is an editing window;
if (currentWindow.WindowType == WindowType.Editor)
{
   MessageBox.Show("Number of task panes: " + 
      currentWindow.TaskPanes.Count.ToString());
}
' Set a reference to the current window.
Dim currentWindow As Window  = Me.Application.ActiveWindow

' Check if the window is an editing window;
If currentWindow.WindowType = WindowType.Editor Then
   MessageBox.Show("Number of task panes: " & _
      currentWindow.TaskPanes.Count.ToString())
End If

Remarks

The Window objects represent the two types of windows that are used in the InfoPath application: the editing window that displays a form when a user fills out a form, and the designing window that is used in design mode when a user designs a form template.

The Window object provides 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 the XmlForm property for accessing the form's underlying XML document that is associated with the window.

The Window objects of an InfoPath form are accessed through the Item[Int32] property of the WindowCollection object. The type of window can be determined by using the WindowType property.

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

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.

Constructors

Window()

Properties

Active

Gets a value that indicates whether the window associated with the Window object is the active window.

Caption

Gets or sets the caption text for the window represented by the Window object.

CommandBars

Gets a reference to the Microsoft Office CommandBars collection of the window that is associated with the Window object.

Height

Gets or sets the height of the window represented by the Window object, measured in points.

Left

Gets or sets the horizontal position of the window represented by the Window object, measured in points.

MailEnvelope

Gets a reference to the MailEnvelope object associated with the window that is represented by the Window object.

TaskPanes

Gets a reference to the TaskPaneCollection collection that is associated with the Window object.

Top

Gets or sets the vertical position of the window represented by the Window object, measured in points.

Width

Gets or sets the width of the window represented by the Window object, measured in points.

WindowState

Gets or sets the state of the window represented by the Window object.

WindowType

Gets the type of window that is represented by the Window object.

XmlForm

Gets a reference to the XmlForm object that is associated with the window that is represented by the Window object.

Methods

Activate()

Activates (gives focus to) the window that is represented by the Window object.

Close()

Closes the window that is represented by the Window object prompting to save changes to any unsaved form, or form with changes that have not been saved.

Close(Boolean)

Closes the window that is represented by the Window object and optionally forces an unsaved form or form with unsaved changes to be closed without saving.

Applies to