Compartilhar via


IVsProject2.OpenItem Method

Opens an item in the project.

Namespace:  Microsoft.VisualStudio.Shell.Interop
Assembly:  Microsoft.VisualStudio.Shell.Interop (in Microsoft.VisualStudio.Shell.Interop.dll)

Syntax

'Declaration
Function OpenItem ( _
    itemid As UInteger, _
    ByRef rguidLogicalView As Guid, _
    punkDocDataExisting As IntPtr, _
    <OutAttribute> ByRef ppWindowFrame As IVsWindowFrame _
) As Integer
int OpenItem(
    uint itemid,
    ref Guid rguidLogicalView,
    IntPtr punkDocDataExisting,
    out IVsWindowFrame ppWindowFrame
)
int OpenItem(
    [InAttribute] unsigned int itemid, 
    [InAttribute] Guid% rguidLogicalView, 
    [InAttribute] IntPtr punkDocDataExisting, 
    [OutAttribute] IVsWindowFrame^% ppWindowFrame
)
abstract OpenItem : 
        itemid:uint32 * 
        rguidLogicalView:Guid byref * 
        punkDocDataExisting:IntPtr * 
        ppWindowFrame:IVsWindowFrame byref -> int
function OpenItem(
    itemid : uint, 
    rguidLogicalView : Guid, 
    punkDocDataExisting : IntPtr, 
    ppWindowFrame : IVsWindowFrame
) : int

Parameters

  • itemid
    Type: UInt32

    [in] Identifier of the item to open. Should be VSITEMID_ROOT or other valid item identifier. See the VSITEMID enumeration.

  • rguidLogicalView
    Type: Guid%

    [in] Unique identifier of the logical view. If not GUID_NULL, indicates a specific type of view to create. For more information, see the LOGVIEWID.

  • punkDocDataExisting
    Type: IntPtr

    [in] Pointer to the document data object of the item to open. If the caller of OpenItem had a pointer to the document data object, it would pass it in the punkDocDataExisting parameter. If the caller knew that the document data object was not open, it would pass nulla null reference (Nothing in Visual Basic). If the caller did not know if the document data object was open or if it did not want to look it up in the running document table (RDT) to find out, then it could pass in DOCDATAEXISTING_UNKNOWN. If this value is passed, then OpenStandardEditor will look up the value in the RDT by calling FindAndLockDocument (RDT_EditLock) to determine whether the file (DocData) is already open.

Return Value

Type: Int32
If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From vsshell.idl:

HRESULT IVsProject2::OpenItem(
   [in] VSITEMID itemid,
   [in] REFGUID rguidLogicalView,
   [in] IUnknown *punkDocDataExisting,
   [out] IVsWindowFrame **ppWindowFrame
);

By implementing IVsProjectSpecificEditorMap2 Interface on your project object, you can do project-specific handling of files. That is, you can support either opening the file in a project-specific editor or allowing the global editor to open the item. Opening an item requires launching an editor using OpenStandardEditor or OpenSpecificEditor, depending on the handling you want to implement. For more information, see GetSpecificEditorProperty.

Note

In your implementation of OpenItem, do not call Show on the window frame you return in ppWindowFrame.

Compare to ReopenItem method.

.NET Framework Security

See Also

Reference

IVsProject2 Interface

Microsoft.VisualStudio.Shell.Interop Namespace