EditorFactory.CreateEditorInstance Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
This method checks to see if the specified file is one that your editor supports and if so, creates the core text editor and associated your language service with it. To figure out if the file is one that your editor supports it performs the following check:
If all this is true then it goes ahead with the next step which is to get an IVsTextLines buffer and set it up as follows:
Lastly it calls CreateEditorView to create the docView.
public:
virtual int CreateEditorInstance(System::UInt32 createDocFlags, System::String ^ moniker, System::String ^ physicalView, Microsoft::VisualStudio::Shell::Interop::IVsHierarchy ^ pHier, System::UInt32 itemid, IntPtr existingDocData, [Runtime::InteropServices::Out] IntPtr % docView, [Runtime::InteropServices::Out] IntPtr % docData, [Runtime::InteropServices::Out] System::String ^ % editorCaption, [Runtime::InteropServices::Out] Guid % cmdUI, [Runtime::InteropServices::Out] int % cancelled);
public virtual int CreateEditorInstance (uint createDocFlags, string moniker, string physicalView, Microsoft.VisualStudio.Shell.Interop.IVsHierarchy pHier, uint itemid, IntPtr existingDocData, out IntPtr docView, out IntPtr docData, out string editorCaption, out Guid cmdUI, out int cancelled);
abstract member CreateEditorInstance : uint32 * string * string * Microsoft.VisualStudio.Shell.Interop.IVsHierarchy * uint32 * nativeint * nativeint * nativeint * string * Guid * int -> int
override this.CreateEditorInstance : uint32 * string * string * Microsoft.VisualStudio.Shell.Interop.IVsHierarchy * uint32 * nativeint * nativeint * nativeint * string * Guid * int -> int
Public Overridable Function CreateEditorInstance (createDocFlags As UInteger, moniker As String, physicalView As String, pHier As IVsHierarchy, itemid As UInteger, existingDocData As IntPtr, ByRef docView As IntPtr, ByRef docData As IntPtr, ByRef editorCaption As String, ByRef cmdUI As Guid, ByRef cancelled As Integer) As Integer
Parameters
- createDocFlags
- UInt32
Flags that define the conditions under which to create the core editor.
- moniker
- String
String form of the moniker identifier of the document in the project system. In the case of documents that are files, this is always the path to the file. This parameter can also be used to specify documents that are not files. For example, in a database-oriented project, this parameter could contain a string that refers to records in a table.
- physicalView
- String
Name of the physical view.
- pHier
- IVsHierarchy
An IVsHierarchy object.
- itemid
- UInt32
Item identifier of the core editor instance.
- existingDocData
-
IntPtr
nativeint
Must be the docData
object that is registered in the Running Document Table (RDT). This parameter is used to determine if a document buffer (Document Data object) has already been created. When an editor factory is asked to create a secondary view, then this parameter will be non-NULL
indicating that there is no document buffer.
- docView
-
IntPtr
nativeint
Document View object. Returns NULL
if an external editor exists, otherwise returns the view of the document.
- docData
-
IntPtr
nativeint
Document Data object. Returns the buffer for the document.
- editorCaption
- String
Initial caption defined by the document editor for the document window. This is typically a string enclosed in square brackets, such as "[Form]". This value is passed as an input parameter to the CreateDocumentWindow(UInt32, String, IVsUIHierarchy, UInt32, IntPtr, IntPtr, Guid, String, Guid, IServiceProvider, String, String, Int32[], IVsWindowFrame) method. If the file is [ReadOnly] the caption will be set during load of the file.
- cmdUI
- Guid
Returns the Command UI GUID. This GUID is active when this editor is activated. Any UI element that is visible in the editor has to use this GUID. This GUID is used in the .ctc file in the satellite DLL where it indicates which menus and toolbars should be displayed when the document is active.
- cancelled
- Int32
Enumeration of type __VSEDITORCREATEDOCWIN. These flags are passed to CreateDocumentWindow(UInt32, String, IVsUIHierarchy, UInt32, IntPtr,
IntPtr, Guid, String, Guid, IServiceProvider, String, String,
Int32[], IVsWindowFrame) Method. This value is set to 0
in the EditorFactory implementation.
Returns
If the method succeeds, it returns S_OK. If it fails, it returns an error code.
Implements
Remarks
For an example of how to use this method, see Walkthrough: Creating a Core Editor and Registering an Editor File Type.