IPersistMessage::SaveCompleted

The IPersistMessage::SaveCompleted method notifies the form that a save operation has been completed.

Quick Info

See IPersistMessage : IUnknown.

HRESULT SaveCompleted(
  LPMESSAGE pMessage  
);
 

Parameters

pMessage
[in] Pointer to the newly saved message.

Return Values

S_OK
The notification was successful.
E_INVALIDARG
The pMessage parameter is NULL and the form is either in the Hands Off From Normal or Hands Off After Save state.
E_UNEXPECTED
The form is not in one of the following states:

Remarks

The IPersistMessage::SaveCompleted method is called by a form viewer to notify the form that all pending changes have been saved. SaveCompleted should only be called when the form is in one of the following states:

Notes to Implementers

There are several possible actions that the SaveCompleted method can perform, depending on what the message pointer parameter contains, and what state the message is in. However, when an action is successful, always save the current state of the message pointed to by the pMessage parameter and transition the form to its Normal state.

The following table describes the variables that affect the actions you should take in your implementation of SaveCompleted:

Condition Action
The pMessage parameter is NULL and the fSameAsLoad parameter to Save was set to TRUE. Call the IMAPIViewAdviseSink::OnSaved method of all registered viewers, mark the form as clean, and return S_OK.
The pMessage parameter is NULL and the fSameAsLoad parameter to Save was set to FALSE. Return S_OK.
The form is in the Hands Off From Normal state. Release the current message and replace it with the message pointed to by pMessage. Call the replacement message's IUnknown::AddRef method and return S_OK.
The form is in the Hands Off After Save state. Call the IMAPIViewAdviseSink::OnSaved method of all registered viewers, mark the form as clean, and return S_OK.
The form is in the No Scribble state. Release the current message and replace it with the message pointed to by pMessage. Call the replacement message's IUnknown::AddRef method. Call the IMAPIViewAdviseSink::OnSaved method of all registered viewers, mark the form as clean, and return S_OK.
The form is in one of the Hands Off states and the pMessage parameter is set to NULL. Return E_INVALIDARG.
The form is in a state other than one of the Hands Off states or the No Scribble state. Return E_UNEXPECTED.

For more information on saving storage objects, see the documentation for one of the following methods in the OLE Programmer's Reference:

IPersistFile::SaveCompleted

IPersistStorage::SaveCompleted