IVsQueryUndoUnit::ActionWouldBeAborted Method (Int32)
Queries each member of a linked undo set to determine if an undo action would be aborted.
Assembly: Microsoft.VisualStudio.TextManager.Interop.8.0 (in Microsoft.VisualStudio.TextManager.Interop.8.0.dll)
Parameters
- pbWouldBeAborted
-
Type:
System::Int32
[out] If 1 (TRUE), undo action would be aborted; if 0 (FALSE) undo action would not be aborted.
Return Value
Type: System::Int32If the method succeeds, it returns S_OK. If it fails, it returns an error code.
A linked undo set tracks the same undo action in multiple buffers.
This interface queries a linked undo set to allow each member of the set to determine if an undo action would be aborted.
Call this method before attempting a linked undo in order to avoid having to roll back linked undo actions.
Notes to Implementers:
Implement this method for the initial parent of a linked undo set. In the implementation, query each undo child and call ActionWouldBeAborted if the child supports IVsQueryUndoUnit.
In this C++ example, the parent stops querying if any child returns true:
STDMETHODIMP CParentUndoUnit::ActionWouldBeAborted ( BOOL *pbWouldBeAborted // [out] Would the action be aborted? ) { HRESULT hr = S_OK; if ( pbWouldBeAborted == NULL ) { hr = E_POINTER; } else { *pbWouldBeAborted = FALSE; // Loop over child units for edit actions CEditNode *pNode = m_pEditFirst; while (pNode && SUCCEEDED(hr)) { if (pNode->m_pEditUnit) { CComQIPtr<IVsQueryUndoUnit, &IID_IVsQueryUndoUnit> srpQueryUndoUnitForUserAbort(pNode->m_pEditUnit); if ( srpQueryUndoUnitForUserAbort ) { hr = srpQueryUndoUnitForUserAbort->ActionWouldBeAborted(pbWouldBeAborted); // If any action would be aborted, stop looking if ( SUCCEEDED(hr) && *pbWouldBeAborted == TRUE ) { break; } } } pNode = pNode->m_pNext; } } return hr; }