This documentation is archived and is not being maintained.

How to: Open Project-Specific Editors

If an item file being opened by a project is intrinsically bound to the particular editor for that project, the project must open the file by using a project-specific editor. The file cannot be delegated down to the IDE's mechanism for selecting an editor. For example, instead of using a standard bitmap editor, you can use this project-specific editor option to specify a specific bitmap editor that recognizes information in the file that is unique to your project.

The IDE calls the OpenItem method when it determines that a file should be opened by a specific project. For more information, see Displaying Files By Using the Open File Command. Use the following guidelines to implement the OpenItem method to have your project open a file by using a project-specific editor.

To implement the OpenItem method with a project-specific editor

  1. Call the FindAndLockDocument method (RDT_EditLock) to determine whether the file (document data object) is already open.

    NoteNote

    For more information about document data and document view objects, see Document Data and Document View in Custom Editors.

  2. If the file is already open, resurface the file by calling the IsDocumentOpen method and specifying a value of IDO_ActivateIfOpen for the grfIDO parameter.

    If the file is open and the document is owned by a project other than the calling project, a warning will be displayed to the user that the editor being opened is from another project. The file window is then surfaced.

  3. If your text buffer (document data object) is already open and you want to attach another view to it, you are responsible for hooking up that view. The recommended approach to instantiating a view (document view object) from the project, is as follows:

    1. Call QueryService on the SLocalRegistry service to get a pointer to the ILocalRegistry2 interface.

    2. Call the CreateInstance method to create an instance of the document view class.

  4. Call the CreateDocumentWindow method, specifying your document view object.

    This method sites the document view object in a document window.

  5. Perform the appropriate calls to either the InitNew or the Load methods.

    At this point, the view should be fully initialized and ready to be opened.

  6. Call the Show method to show and open the view.

Show: