Share via


Windows Object

Home Page (Objects)OverviewFAQReference

The Windows object represents a collection of open windows. This collection can represent all windows open in Developer Studio or only windows open on a document. For example, if you access the Windows object by using the Windows property of the Application object, the collection represents all windows open in Developer Studio. However, if a document is open and you use the Windows property of the Document object, the collection represents only windows open on the document.

The Windows object has the following properties and methods:

Properties
Application _NewEnum
Count Parent
Methods
Arrange Item
CloseAll

The Windows object is a collection object that contains all Window objects. To find a particular object, iterate through the collection by using For Each ... Next in a VBScript macro.

Consider the following code snippet:

Dim myWindow
For Each myWindow in Application.Windows
   ' Access myWindow here.
   ' For example:
    MsgBox myWindow.Caption
Next

In Visual C++, you can iterate through the Windows collection by using the Item method or _NewEnum property.

When you reference the Windows collection, the reference always reflects the current contents of the collection. For example, suppose you have two macros (A and B). In macro A, you set a global variable to the collection, and in macro B you use the variable. When you use it, the variable will reflect the current contents of the collection — not the contents present when you set the variable.

Using a Dual Interface to Access This Object

This section about dual interfaces is useful for writing add-ins or automating Developer Studio across processes. This section is not applicable to writing VBScript macros.

The Windows object implements the IWindows dual interface. Through this interface, add-ins can directly access the members (properties, methods, and events) of this object and can employ early binding to make calls into these members faster at run time.

Add-ins written in Visual C++ can access members of the Windows object by using the header files in Vc98\Include\objmodel. However, if you use the Developer Studio Add-in Wizard to create an add-in, the wizard automatically includes these header files in your source code.

The following table shows the header files you need for the Windows object:

Header file Description
appauto.h Declares the dual interfaces.
appguid.h Declares the GUIDs used to identify the interfaces.
appdefs.h Declares additional information needed to use the interfaces, such as error IDs and enumerated constants.

Add-ins written in Visual Basic can access members of the Windows object by using the Visual Studio '97 Shared Objects type library, located in Msdev98\bin\devshl.dll.

Note   Visual Studio '97 Shared Objects is the name that appears in the Visual Basic References dialog box.