2

ここで説明する手順を使用して、VSProject で新しいドキュメント (作成中のドキュメント) を開こうとしています。

しかし、私はあまり成功していません.上記のリンクは、IVsUIShell.CreateDocumentWindow-2147024809を呼び出す必要があることを示していますが、 ( )の戻り値を取得しFFFFFFFF80070057、出力ppWindowFrameはnullです.

私は何を間違っていますか?この方法を使用して新しいドキュメント ウィンドウを作成する方法の例はありますか?

これは私がこれまでに持っているものです:

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

からの戻り値FindAndLockDocument1( S_FALSE) です。これは、ドキュメントが見つからなかったことを意味すると思います。itemIdこれはuint.MaxValue間違いなく悪い兆候です - を呼び出す前に、何らかの方法で実行中のドキュメント テーブルにエントリを作成する必要がありますCreateDocumentWindowか? もしそうなら、どうすればいいですか?

地上をカバーする例やサンプルは非常に役に立ちます。

4

1 に答える 1

2

私は最終的に、MSDN フォーラムのこのスレッドの助けを借りてこれを管理しました。

私のコードはIVsUIShellOpenDocumentインターフェイスとOpenDocumentViaProjectWithSpecificメソッドを使用するようになりました - 次のスニペットは基本的なものですが、実際には機能します:

IVsUIShellOpenDocument shellOpenDocument = (IVsUIShellOpenDocument)GetService(typeof(IVsUIShellOpenDocument));

string mkDocument = "MyUniqueDocumentId";

// This is the GUID for the editor factory, i.e. the one that appears in the Guid attribute on your
// editor factory (that implements IVsEditorFactory): [Guid(GuidList.guid_VSPackageEditorFactory)]
Guid xmlGuid = GuidList.guid_VSPackageEditorFactory;

string physicalView = null;
Guid logicalViewGuid = VSConstants.LOGVIEWID_Primary;
Microsoft.VisualStudio.OLE.Interop.IServiceProvider ppSP;
IVsUIHierarchy ppHier;
uint pitemid;
IVsWindowFrame ppWindowFrame;

shellOpenDocument.OpenDocumentViaProjectWithSpecific(
    mkDocument,
    (uint)__VSSPECIFICEDITORFLAGS.VSSPECIFICEDITOR_DoOpen,
    ref xmlGuid,
    physicalView, 
    ref logicalViewGuid, 
    out ppSP, 
    out ppHier, 
    out pitemid, 
    out ppWindowFrame);

if (ppWindowFrame != null)
{
    ppWindowFrame.Show();
}
于 2011-03-21T08:09:53.433 に答える