共用方式為


WindowsCollection 介面

包含目前開啟之每一個 Microsoft Office InfoPath 2003 視窗的 WindowObject 物件。

**命名空間:**Microsoft.Office.Interop.InfoPath
**組件:**Microsoft.Office.Interop.InfoPath (於 microsoft.office.interop.infopath.dll 中)

語法

'宣告
<GuidAttribute("096CD58B-0786-11D1-95FA-0080C78EE3BB")> _
<CoClassAttribute(GetType(WindowsCollectionClass))> _
Public Interface WindowsCollection
    Inherits Windows
'用途
Dim instance As WindowsCollection
[GuidAttribute("096CD58B-0786-11D1-95FA-0080C78EE3BB")] 
[CoClassAttribute(typeof(WindowsCollectionClass))] 
public interface WindowsCollection : Windows

備註

此類型為 coclass 實作之 COM 介面的包裝函式,屬於 COM 互通性中 Managed 程式碼的必要項。使用包裝實作此介面之 coclass 的類型,即可存取此介面指定的成員。如需該類型 (包括用法、備註及範例) 的詳細資訊,請參閱 Windows

WindowObject 物件代表 InfoPath 應用程式中使用的兩種視窗:使用者填寫表單時做為表單區域的編輯視窗,及使用者設計表單時做為設計模式的設計視窗。

WindowsCollection 集合會實作可用來存取表單的關聯 Windows 物件的屬性,而它是透過 Application 物件的 Windows 屬性來存取。

注意

WindowsCollection 集合僅可用於取得其包含之 WindowObject 物件的計數,或傳回指定之 WindowObject 物件的參考;而無法用於建立、新增或移除 WindowObject 物件。

範例

在下列範例中,當實作為表單按鈕的 OnClick 事件處理常式時,Application 物件的 Windows 屬性會用來設定 WindowsCollection 集合的參考。接著程式碼會在集合中執行迴圈,並顯示每個 Windows 物件所包含的類型。

public void ShowWindowTypes_OnClick(DocActionEvent e)
{
// Set a reference to the Windows collection.
WindowsCollection windows = thisApplication.Windows;

// Loop through the collection and display the type
// of each Window object that it contains.
for (int i=0; i < windows.Count; i++)
 {
string windowType = "";

switch (windows[i].WindowType)
    {
    case XdWindowType.xdEditorWindow:
    windowType = "Editing window";
    break;

    case XdWindowType.xdDesignerWindow:
    windowType = "Designing window";
    break;
    }

thisXDocument.UI.Alert("Window type " + i + ": " + windowType);
 }
}

如需程式碼範例,請參閱 操作方法:使用表單視窗

請參閱

參考

WindowsCollection 成員
Microsoft.Office.Interop.InfoPath 命名空間