IPersistFile::IsDirty method (objidl.h)
Determines whether an object has changed since it was last saved to its current file.
This method returns S_OK to indicate that the object has changed. Otherwise, it returns S_FALSE.
Use this method to determine whether an object should be saved before closing it. The dirty flag for an object is conditionally cleared in the IPersistFile::Save method.
You should treat any error return codes as an indication that the object has changed. Unless this method explicitly returns S_FALSE, assume that the object must be saved.
A container with one or more contained objects must maintain an internal dirty flag that is set when any of its contained objects has changed since it was last saved. To do this, the container should maintain an advise sink by implementing the IAdviseSink interface. Then, the container can register each link or embedding for data change notifications with a call to IDataObject::DAdvise. Then, the container can set its internal dirty flag when it receives an IAdviseSink::OnDataChange notification. If the container does not register for data change notifications, the IPersistFile::IsDirty implementation would call IPersistStorage::IsDirty for each of its contained objects to determine whether they have changed.
The container can clear its dirty flag whenever it is saved, as long as the file to which the object is saved is the current working file after the save. Therefore, the dirty flag would be cleared after a successful Save or Save As operation, but not after a Save A Copy As . . . operation.
|Minimum supported client||Windows 2000 Professional [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|