Udostępnij za pośrednictwem


IVsProjectSpecificEditorMap2.GetSpecificEditorProperty Method

Gets properties related to project-specific editors and the Open With dialog box.

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

Syntax

'Declaration
Function GetSpecificEditorProperty ( _
    pszMkDocument As String, _
    propid As Integer, _
    <OutAttribute> ByRef pvar As Object _
) As Integer
int GetSpecificEditorProperty(
    string pszMkDocument,
    int propid,
    out Object pvar
)
int GetSpecificEditorProperty(
    [InAttribute] String^ pszMkDocument, 
    [InAttribute] int propid, 
    [OutAttribute] Object^% pvar
)
abstract GetSpecificEditorProperty : 
        pszMkDocument:string * 
        propid:int * 
        pvar:Object byref -> int 
function GetSpecificEditorProperty(
    pszMkDocument : String, 
    propid : int, 
    pvar : Object
) : int

Parameters

  • pszMkDocument
    Type: System.String
    [in] String form of the unique moniker identifier of the document in the project system.
  • pvar
    Type: System.Object%
    [out, retval] Pointer to a VARIANT containing the property value.

Return Value

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

Remarks

COM Signature

From vsshell.idl:

HRESULT IVsProjectSpecificEditorMap2::GetSpecificEditorProperty(
   [in] LPCOLESTR pszMkDocument,
   [in] VSPSEPROPID propid,
   [out, retval] VARIANT *pvar
);

If you support the VSPSEPROPID_UseGlobalEditorByDefault property and return true, then the global editor is used by default. If false, then a project-specific editor is used by default. If you support this property, then a "<project default editor>" entry is added to the Open With dialog box. This entry is always placed at the top of the Open With dialog box. To set this string to be something other than "<project default editor>", support IVsProjectSpecificEditorMap::GetSpecificEditorProperty (VSPSEPROPID_ProjectDefaultEditorName). Setting this property is optional.

The project is expected to persist (on a per-user/per-machine/per file type basis in the registry under HKEY_CURRENTUSER) whether the global standard editor or the project-specific editor should be used. The project then uses this information to know whether to call OpenStandardEditor or OpenSpecificEditor when opening a project item.

The following is a complicated scenario you can accomplish with this approach. You have a project system that has special handling for XML files. That is, the project system provides a special editing experience for XML files. The user can choose between using the special (project-preferred) editor for XML files, or using the globally-defined editor. The user chooses to open the XML file in the text editor. To do this, they set the text editor as the default editor in the Open With dialog box. Subsequently, when a user double-clicks an xml file in the project, the text editor opens the file.

Later, the user goes to another project (for example, the Miscellaneous Files project), right-clicks on the file, and sets the XML editor as the default editor for xml files. If the user then returns to the original project and double-clicks on the xml file, the file now opens in the XML editor instead of the text editor. However, if the user had originally decided that the project system should use the XML editor by default, then regardless of what editor is set as the global editor elsewhere, the xml files in that project would be opened using the project-specific editor, which was set as the default editor for the project. Both the VB and the C# project systems provide special editors for various types of files.

.NET Framework Security

See Also

Reference

IVsProjectSpecificEditorMap2 Interface

Microsoft.VisualStudio.Shell.Interop Namespace