我正在尝试使用此处描述的步骤在我的 VSProject 中打开一个新文档(我正在创建的文档):
但是我没有取得太大的成功 - 上面的链接告诉我应该调用IVsUIShell.CreateDocumentWindow但是我得到-2147024809
( FFFFFFFF80070057
) 的返回值并且输出ppWindowFrame
为空。
我究竟做错了什么?有没有关于如何使用此方法创建新文档窗口的示例?
这是我到目前为止所拥有的:
int retval = rdt.FindAndLockDocument(
(uint)_VSRDTFLAGS.RDT_EditLock, // dwRDTLockType
myDocumentUniqueIdentifier, // pszMkDocument
out hierachy, // ppHier
out itemId, // pitemid
out docData, // ppunkDocData
out cookie); // pdwCookie
IVsWindowFrame windowFrame;
Guid emptyGuid = Guid.Empty;
Guid editorType = new Guid(GuidList.VSPackageEditorFactoryString);
// I know that the document is not open
retval = shell.CreateDocumentWindow(
0, // grfCDW
myDocumentUniqueIdentifier, // pszMkDocument
(IVsUIHierarchy)hierachy, // pUIH
itemId, // itemid
IntPtr.Zero, // punkDocView
docData, // punkDocData
ref editorType, // rguidEditorType
"MyPhysicalView", // pszPhysicalView
ref emptyGuid, // rguidCmdUI
this, // psp
"New document", // pszOwnerCaption
"New document", // pszEditorCaption
null, // pfDefaultPosition
out windowFrame); // ppWindowFrame
FindAndLockDocument
来自( )的返回值1
,S_FALSE
我认为这意味着未找到该文档。itemId
这绝对是uint.MaxValue
一个坏信号 - 在调用之前我是否需要在运行的文档表中创建一个条目CreateDocumentWindow
?如果是这样,我该怎么做?
任何涵盖上述内容的示例或样本都会非常有帮助。