Udostępnij za pośrednictwem


IVsProjectSpecificEditorMap2.GetSpecificEditorProperty Method

Definition

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

public:
 int GetSpecificEditorProperty(System::String ^ pszMkDocument, int propid, [Runtime::InteropServices::Out] System::Object ^ % pvar);
int GetSpecificEditorProperty(std::wstring const & pszMkDocument, int propid, [Runtime::InteropServices::Out] winrt::Windows::Foundation::IInspectable const & & pvar);
public int GetSpecificEditorProperty (string pszMkDocument, int propid, out object pvar);
abstract member GetSpecificEditorProperty : string * int * obj -> int
Public Function GetSpecificEditorProperty (pszMkDocument As String, propid As Integer, ByRef pvar As Object) As Integer

Parameters

pszMkDocument
String

[in] String form of the unique moniker identifier of the document in the project system.

propid
Int32

[in] If equal to VSPSEPROPID_UseGlobalEditorByDefault (false) then the user has chosen to open the file in the project-specific editor information listed in the Open With dialog box. If VSPSEPROPID_UseGlobalEditorByDefault (true), then the global editor was chosen. For more information, see __VSPSEPROPID.

pvar
Object

[out, retval] Pointer to a VARIANT containing the property value.

Returns

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.

Applies to