Share via


IVsUIShellOpenDocument3.SetNewDocumentState Method

Determines whether, on subsequent documents open calls like OpenStandardEditor, the document will be opened provisionally or permanently. Allows an entity that is far removed from the IVsUIShellOpenDocument calls that opened a document to control how it is opened–provisionally or permanently.

Namespace:  Microsoft.VisualStudio.Shell.Interop
Assemblies:   Microsoft.VisualStudio.Shell.Interop.11.0 (in Microsoft.VisualStudio.Shell.Interop.11.0.dll)
  Microsoft.VisualStudio.Shell.11.0 (in Microsoft.VisualStudio.Shell.11.0.dll)

Syntax

'Declaration
Function SetNewDocumentState ( _
    state As UInteger, _
    ByRef reason As Guid _
) As IVsNewDocumentStateContext
IVsNewDocumentStateContext SetNewDocumentState(
    uint state,
    ref Guid reason
)
IVsNewDocumentStateContext^ SetNewDocumentState(
    [InAttribute] unsigned int state, 
    [InAttribute] Guid% reason
)
abstract SetNewDocumentState : 
        state:uint32 * 
        reason:Guid byref -> IVsNewDocumentStateContext
function SetNewDocumentState(
    state : uint, 
    reason : Guid
) : IVsNewDocumentStateContext

Parameters

  • state
    Type: System.UInt32

    [in] The state used for the next document to be opened.

  • reason
    Type: System.Guid%

    [in] The reason the state is being set (typically this is a tool window or language service GUID).

Return Value

Type: Microsoft.VisualStudio.Shell.Interop.IVsNewDocumentStateContext
An IVsNewDocumentStateContext used to restore the document state.

Remarks

The returned IVsNewDocumentStateContext is not intended to be long-lived; callers of this method should call Restore (or release the context) immediately after the document is opened.

If you call this method with NDS_Provisional and then start the process to open a file, the file will be opened even if provisional viewing is not enabled for the file or its editor. If you only want to open a file if you know that it will be opened provisionally, you should make that determination using either GetProvisionalViewingStatusForFile or GetProvisionalViewingStatusForEditor and only call this method and open the file if they indicate provisional viewing is enabled.

You can also open a file in the Visual Studio preview tab by placing the calls to open it within a using statement, see NewDocumentStateScope.

.NET Framework Security

See Also

Reference

IVsUIShellOpenDocument3 Interface

Microsoft.VisualStudio.Shell.Interop Namespace