IVsQueryUndoUnit.ActionWouldBeAborted Method
Queries each member of a linked undo set to determine if an undo action would be aborted.
Namespace: Microsoft.VisualStudio.TextManager.Interop
Assembly: Microsoft.VisualStudio.TextManager.Interop.8.0 (in Microsoft.VisualStudio.TextManager.Interop.8.0.dll)
Syntax
'Declaration
Function ActionWouldBeAborted ( _
<OutAttribute> ByRef pbWouldBeAborted As Integer _
) As Integer
int ActionWouldBeAborted(
out int pbWouldBeAborted
)
int ActionWouldBeAborted(
[OutAttribute] int% pbWouldBeAborted
)
abstract ActionWouldBeAborted :
pbWouldBeAborted:int byref -> int
function ActionWouldBeAborted(
pbWouldBeAborted : int
) : int
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.Int32
If the method succeeds, it returns S_OK. If it fails, it returns an error code.
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.
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;
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Microsoft.VisualStudio.TextManager.Interop Namespace
IVsLinkedUndoTransactionManager