次の方法で共有


Saving a Custom Document

The environment handles the Save, Save As, and Save All commands. When a user clicks Save, Save As, or Save All on the File menu or closes the solution, resulting in a Save All, the following process occurs.

Save, Save As, and Save All command handling for a custom editor

Customer Editor Save

This process is detailed in the following steps:

  1. For the Save and Save As commands, the environment uses the SVsShellMonitorSelection service to determine the active document window and thus what items should be saved. Once the active document window is known, the environment finds the hierarchy pointer and item identifier (itemID) for the document in the running document table. For more information, see Running Document Table.

    For the Save All command, the environment uses the information in the running document table to compile the list of all items to save.

  2. When the solution receives an QueryStatus call, it iterates through the set of selected items (that is, the multiple selections exposed by the SVsShellMonitorSelection service).

  3. On each item in the selection, the solution uses the hierarchy pointer to call the IsItemDirty method to determine whether the Save menu command should be enabled. If one or more items are dirty, then the Save command is enabled. If the hierarchy uses a standard editor, then the hierarchy delegates querying for dirty status to the editor by calling the IsDocDataDirty method.

  4. On each selected item that is dirty, the solution uses the hierarchy pointer to call the SaveItem method on the appropriate hierarchies.

    In the case of a custom editor, the communication between the document data object and the project is private. Thus, any special persistence concerns are handled between these two objects.

    Note

    If you implement your own persistence, be sure to call the QuerySaveFiles method to save time. This method checks to make sure that it is safe to save the file (for example, the file is not read-only).

See Also

Reference

IOleCommandTarget

Other Resources

Opening and Saving Project Items