Share via


How to: Clear the Undo Stack

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

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;  
    }  
    

See Also

How to: Implement Undo Management