IVsEditorFactory2.RetargetCodeOrDesignerToOpen Method

Re-targets the item opened by View commands.

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

Syntax

'Declaration
Function RetargetCodeOrDesignerToOpen ( _
    pszMkDocumentSource As String, _
    ByRef rguidLogicalViewSource As Guid, _
    pvHier As IVsHierarchy, _
    itemidSource As UInteger, _
    <OutAttribute> ByRef pitemidTarget As UInteger, _
    <OutAttribute> ByRef pgrfEditorFlags As UInteger, _
    <OutAttribute> ByRef pguidEditorTypeTarget As Guid, _
    <OutAttribute> ByRef pbstrPhysicalViewTarget As String, _
    <OutAttribute> ByRef pguidLogicalViewTarget As Guid _
) As Integer
int RetargetCodeOrDesignerToOpen(
    string pszMkDocumentSource,
    ref Guid rguidLogicalViewSource,
    IVsHierarchy pvHier,
    uint itemidSource,
    out uint pitemidTarget,
    out uint pgrfEditorFlags,
    out Guid pguidEditorTypeTarget,
    out string pbstrPhysicalViewTarget,
    out Guid pguidLogicalViewTarget
)
int RetargetCodeOrDesignerToOpen(
    [InAttribute] String^ pszMkDocumentSource, 
    [InAttribute] Guid% rguidLogicalViewSource, 
    [InAttribute] IVsHierarchy^ pvHier, 
    [InAttribute] unsigned int itemidSource, 
    [OutAttribute] unsigned int% pitemidTarget, 
    [OutAttribute] unsigned int% pgrfEditorFlags, 
    [OutAttribute] Guid% pguidEditorTypeTarget, 
    [OutAttribute] String^% pbstrPhysicalViewTarget, 
    [OutAttribute] Guid% pguidLogicalViewTarget
)
abstract RetargetCodeOrDesignerToOpen : 
        pszMkDocumentSource:string * 
        rguidLogicalViewSource:Guid byref * 
        pvHier:IVsHierarchy * 
        itemidSource:uint32 * 
        pitemidTarget:uint32 byref * 
        pgrfEditorFlags:uint32 byref * 
        pguidEditorTypeTarget:Guid byref * 
        pbstrPhysicalViewTarget:string byref * 
        pguidLogicalViewTarget:Guid byref -> int
function RetargetCodeOrDesignerToOpen(
    pszMkDocumentSource : String, 
    rguidLogicalViewSource : Guid, 
    pvHier : IVsHierarchy, 
    itemidSource : uint, 
    pitemidTarget : uint, 
    pgrfEditorFlags : uint, 
    pguidEditorTypeTarget : Guid, 
    pbstrPhysicalViewTarget : String, 
    pguidLogicalViewTarget : Guid
) : int

Parameters

  • pszMkDocumentSource
    Type: System.String

    Original document to open

  • pguidEditorTypeTarget
    Type: System.Guid%

    A GUID specifying the new target editor type.

  • pbstrPhysicalViewTarget
    Type: System.String%

    A string specifying the physical view target.

  • pguidLogicalViewTarget
    Type: System.Guid%

    A GUID specifying the logical view target.s

Return Value

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

Remarks

This method is used to retarget which item is opened for the View Code or View Designer commands for an item. This is used to cause a different file to be opened than the original source item. For example a designer item (like *.xaml) may want to open a nested code-behind item for the ViewCode command instead of the *.xaml file.

NOTE: Return S_OK and *pitemidTarget = VSITEMID_NIL, if you do not want to retarget to a different item.

The project system is expected to call OpenItemWithSpecific with the out parameters returned from this call. A project system's implementation of cmdidViewCode/cmdidViewDesigner should check if the specific IVsEditorFactory that they otherwise would have called using OpenSpecificEditor implements this interface. If so, then they should redirect which item is opened.

COM Signature

From vsshell90.idl:

HRESULT RetargetCodeOrDesignerToOpen(
    [in]  LPCOLESTR              pszMkDocumentSource,
    [in]  REFGUID                rguidLogicalViewSource,
    [in]  IVsHierarchy          *pvHier,
    [in]  VSITEMID               itemidSource,
    [out] VSITEMID              *pitemidTarget,
    [out] VSSPECIFICEDITORFLAGS *pgrfEditorFlags,
    [out] GUID                  *pguidEditorTypeTarget,
    [out] BSTR                  *pbstrPhysicalViewTarget,
    [out] GUID                  *pguidLogicalViewTarget);

.NET Framework Security

See Also

Reference

IVsEditorFactory2 Interface

Microsoft.VisualStudio.Shell.Interop Namespace