title | description | ms.date | ms.topic | helpviewer_keywords | author | ms.author | manager | ms.subservice | ||
---|---|---|---|---|---|---|---|---|---|---|
Open Standard Editors |
Learn how to implement the OpenItem method with a standard editor. The IDE determines a standard editor for a designated file type. |
11/04/2016 |
how-to |
|
maiak |
maiak |
mijacobs |
extensibility-integration |
When you open a standard editor, you let the IDE determine a standard editor for a designated file type, instead of specifying a project-specific editor for the file.
Complete the following procedure to implement the xref:Microsoft.VisualStudio.Shell.Interop.IVsProject3.OpenItem%2A method. This will open a project file in a standard editor.
-
Call xref:Microsoft.VisualStudio.Shell.Interop.IVsRunningDocumentTable (
RDT_EditLock
) to determine whether the document data object file is already open. -
If the file is already open, resurface the file by calling the xref:Microsoft.VisualStudio.Shell.Interop.IVsUIShellOpenDocument.IsDocumentOpen%2A method, specifying a value of
IDO_ActivateIfOpen
for thegrfIDO
parameter.If the file is open and the document is owned by a different project than the calling project, your project receives a warning that the editor being opened is from another project. The file window is then surfaced.
-
If the document is not open or not in the running document table, call the xref:Microsoft.VisualStudio.Shell.Interop.IVsUIShellOpenDocument.OpenStandardEditor%2A method (
OSE_ChooseBestStdEditor
) to open a standard editor for the file.When you call the method, the IDE performs the following tasks:
-
The IDE scans the Editors/{guidEditorType}/Extensions subkey in the registry to determine which editor can open the file and has the highest priority for doing this.
-
After the IDE has determined which editor can open the file, the IDE calls xref:Microsoft.VisualStudio.Shell.Interop.IVsEditorFactory.CreateEditorInstance%2A. The editor's implementation of this method returns information that is required for the IDE to call xref:Microsoft.VisualStudio.Shell.Interop.IVsUIShell.CreateDocumentWindow%2A and site the newly opened document.
-
Finally, the IDE loads the document by using the usual persistence interface, such as xref:Microsoft.VisualStudio.Shell.Interop.IVsPersistDocData2.
-
If the IDE has previously determined that the hierarchy or hierarchy item is available, the IDE calls xref:Microsoft.VisualStudio.Shell.Interop.IVsProject3.GetItemContext%2A method on the project to get a project-level context xref:Microsoft.VisualStudio.OLE.Interop.IServiceProvider pointer to pass back in with the xref:Microsoft.VisualStudio.Shell.Interop.IVsUIShell.CreateDocumentWindow%2A method call.
-
-
Return an xref:Microsoft.VisualStudio.OLE.Interop.IServiceProvider pointer to the IDE when the IDE calls xref:Microsoft.VisualStudio.Shell.Interop.IVsProject3.GetItemContext%2A on your project if you want to let the editor get context from your project.
Performing this step lets the project offer additional services to the editor.
If the document view or document view object was successfully sited in a window frame, the object is initialized with its data by calling xref:Microsoft.VisualStudio.Shell.Interop.IVsPersistDocData2.LoadDocData%2A.
- xref:Microsoft.VisualStudio.OLE.Interop.IServiceProvider
- Open and save project items
- How to: Open project-specific editors
- How to: Open editors for open documents
- Display files by using the Open File command