次の方法で共有


Document Data and Document View Objects

An editor consists of two parts: a document data object and a document view object. As the names suggest, the document data object represents the text data to be displayed, and the document view object (or "view") represents one or more windows in which to display the document data object.

Document Data Object

A document data object is a data representation of text in the text buffer. It is a COM object that stores document text and other information, handles document persistence, and enables multiple views of its data. For more information, see

DocumentData and Document Windows.

In the Visual Studio core editor, the document data object is represented by the VsTextBuffer object, which manages the access to and persistence of a stream of Unicode text. Custom editors and designers can opt to use the VsTextBuffer object or their own custom buffer. VsTextBuffer follows the simplified embedding model for a standard editor, supports multiple views, and provides event interfaces that are used to manage multiple views. For more information, see Core Editor.

Document View Object

A window that displays code and other text is known as a document view object or "view" for short. When you create an editor, you can choose either a single view, in which text displays in a single window, or a multiple view, in which text displays in more than one window. Your choice depends on your application. For example, if you need side-by-side editing, you would choose multiple view. Each view is associated with an entry in the intregrated development environment's (IDE) running document table (RDT). View windows belong to a project or an IVsHierarchy object.

If your editor supports multiple views of a document data object, then your document data and view objects must be separate. Otherwise, they can be grouped together. For more information, see Supporting Multiple Document Views.

The IDE notifies views about events — such as when a solution containing a document is closed — by matching an item identifier (ItemID) for each entry in the RDT. For more information on this, see Running Document Table.

There are two options for creating a view for a standard editor. One is the in-place activation model, where the view is hosted in a window using either an ActiveX control or a document data object. The second is the simplified embedding model, where the view is hosted by Visual Studio and IVsWindowPane is implemented to handle window commands. For information about the in-place activation model, see In-Place Activation. For information about simplified embedding model, see Simplified Embedding.

See Also

Concepts

Saving a Standard Document

Persistence and the Running Document Table

Determining Which Editor Opens a File in a Project

Editor Factories

How to: Attach Views to Document Data Objects