How to: Clear the Undo Stack

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at How to: Clear the Undo Stack.

The following procedure below explains how to clear the undo stack.

To clear the undo stack

  1. To clear the undo stack use the IOleUndoManager::DiscardFrom method. The following is an example of this:

    HRESULT CCmdWindow::ClearUndoStack()  
    {  
      HRESULT hr = S_OK;  
    
      if (m_pUndoMgr == NULL)  
        {  
        IfFailGo(m_pTextLines->GetUndoManager(&m_pUndoMgr));  
        ASSERT(m_pUndoMgr != NULL, "",;);  
        }  
    
      IfFailGo(m_pUndoMgr->DiscardFrom(NULL));  
    
    Error:  
      return hr;  
    }  
    
    

How to: Implement Undo Management

Show: