Window Object
Home Page (Objects) | Overview | FAQ | Reference
The Window object represents a multiple document interface (MDI) client window in which a document is being edited.
The Window object has the following properties and methods:
Properties | |
Active | Parent |
Application | Previous |
Caption | Top |
Height | Type |
Index | Width |
Left | WindowState |
Next |
Methods | |
Close |
Each open window is represented by a Window object. This object has members (properties, methods, and events) that you can use to manipulate the window.
If a window is open on a text file, that window also has a TextWindow object. This object has all the members of the Window object and also has members that allow you to access text-specific attributes of the window.
Use the window's Type property to determine which members you can access. If the type is "Generic," the window is not a text window and you can access only Window members. If the type is "Text," the window is a text window, and you can access TextWindow members as well as Window members.
In VBScript macros, you access TextWindow members by automatically using late binding. In Add-ins however, you can also access TextWindow members by using early binding. Early binding offers better performance than late binding by making calls into the interface faster at run time.
You can access the current (active) window by using the ActiveWindow property of the Application object.
All open windows belong to the windows collection represented by the Windows object. You can find a particular window by iterating through this collection.
If any open windows display a document, you can also access the windows collection associated with the document by using the Windows property of the Document object.
Accessing attributes of the main application window
To access attributes of the main application window, use the properties of the Application object, rather than the properties of the Window object.
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 Window object implements the IGenericWindow 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 Window 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 Window 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 Window 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.