IVsQueryUndoUnit.ActionWouldBeAborted(Int32) Method

Definition

Queries each member of a linked undo set to determine if an undo action would be aborted.

public:
 int ActionWouldBeAborted([Runtime::InteropServices::Out] int % pbWouldBeAborted);
int ActionWouldBeAborted([Runtime::InteropServices::Out] int & pbWouldBeAborted);
public int ActionWouldBeAborted (out int pbWouldBeAborted);
abstract member ActionWouldBeAborted : int -> int
Public Function ActionWouldBeAborted (ByRef pbWouldBeAborted As Integer) As Integer

Parameters

pbWouldBeAborted
Int32

[out] If 1 (TRUE), undo action would be aborted; if 0 (FALSE) undo action would not be aborted.

Returns

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Examples

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

Remarks

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.

Applies to