Partager via


IVsUIShellOpenDocument3.SetNewDocumentState(UInt32, Guid) Method

Definition

Determines whether, on subsequent documents open calls like OpenStandardEditor(UInt32, String, Guid, String, IVsUIHierarchy, UInt32, IntPtr, IServiceProvider, IVsWindowFrame), 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.

public:
 Microsoft::VisualStudio::Shell::Interop::IVsNewDocumentStateContext ^ SetNewDocumentState(System::UInt32 state, Guid % reason);
public Microsoft.VisualStudio.Shell.Interop.IVsNewDocumentStateContext SetNewDocumentState (uint state, ref Guid reason);
abstract member SetNewDocumentState : uint32 * Guid -> Microsoft.VisualStudio.Shell.Interop.IVsNewDocumentStateContext
Public Function SetNewDocumentState (state As UInteger, ByRef reason As Guid) As IVsNewDocumentStateContext

Parameters

state
UInt32

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

reason
Guid

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

Returns

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.

Applies to