EditorFactory.CreateEditorInstance 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
這個方法會檢查指定的檔案是否為編輯器支援的檔案,如果是的話,請建立核心文字編輯器,並將您的語言服務與其建立關聯。 若要找出檔案是否為編輯器支援的檔案,請執行下列檢查:
如果這一切成立,則會繼續進行下一個步驟,也就是取得 IVsTextLines 緩衝區,並如下所示進行設定:
最後,它會呼叫 CreateEditorView 來建立 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
參數
- createDocFlags
- UInt32
旗標,定義建立核心編輯器的條件。
- moniker
- String
專案系統中檔的 Moniker 識別碼字串形式。 如果是檔案的檔,這一律是檔案的路徑。 此參數也可以用來指定不是檔案的檔。 例如,在資料庫導向專案中,此參數可能包含參考資料表中記錄的字串。
- physicalView
- String
實體檢視的名稱。
- pHier
- IVsHierarchy
IVsHierarchy 物件。
- itemid
- UInt32
核心編輯器實例的專案識別碼。
- existingDocData
-
IntPtr
nativeint
必須是 docData
在執行中檔資料表中註冊的物件, (RDT) 。 此參數可用來判斷檔案緩衝區 (檔資料物件) 是否已建立。 當系統要求編輯器處理站建立次要檢視時,此參數將不會 NULL
指出沒有檔案緩衝區。
- docView
-
IntPtr
nativeint
檔檢視物件。
NULL
如果外部編輯器存在,則傳回 ,否則會傳回檔的檢視。
- docData
-
IntPtr
nativeint
Document Data 物件。 傳回檔的緩衝區。
- editorCaption
- String
檔視窗的檔編輯器所定義的初始標題。 這通常是以方括弧括住的字串,例如 「[Form]」。 這個值會當做輸入參數傳遞至 CreateDocumentWindow(UInt32, String, IVsUIHierarchy, UInt32, IntPtr, IntPtr, Guid, String, Guid, IServiceProvider, String, String, Int32[], IVsWindowFrame) 方法。 如果檔案是 [ReadOnly] ,則會在檔案載入期間設定標題。
- cmdUI
- Guid
傳回命令 UI GUID。 啟用此編輯器時,此 GUID 為作用中。 編輯器中可見的任何 UI 元素必須使用此 GUID。 此 GUID 會用於附屬 DLL 的 .azure 檔案中,指出檔在使用中時應該顯示哪一個功能表和工具列。
- cancelled
- Int32
型 __VSEDITORCREATEDOCWIN 別 的列舉。 這些旗標會傳遞至 CreateDocumentWindow(UInt32, String, IVsUIHierarchy, UInt32, IntPtr,
IntPtr, Guid, String, Guid, IServiceProvider, String, String,
Int32[], IVsWindowFrame) Method。 這個值會在 實作中設定為 0
EditorFactory 。
傳回
如果方法成功,它會傳回 S_OK。 如果方法失敗,則會傳回錯誤碼。
實作
備註
如需如何使用此方法的範例,請參閱逐步解說 :建立核心編輯器和註冊編輯器檔案類型。