UndoContext.IsAborted Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает сведения о том, была ли операция объекта UndoContext завершена с помощью метода SetAborted().
public:
property bool IsAborted { bool get(); };
public:
property bool IsAborted { bool get(); };
[System.Runtime.InteropServices.DispId(7)]
public bool IsAborted { [System.Runtime.InteropServices.DispId(7)] get; }
[<System.Runtime.InteropServices.DispId(7)>]
[<get: System.Runtime.InteropServices.DispId(7)>]
member this.IsAborted : bool
Public ReadOnly Property IsAborted As Boolean
Значение свойства
Логическое значение, равное true, если операция была прервана, и false в противном случае.
- Атрибуты
Примеры
Sub IsAbortedExample()
' Before running, select text in an open document.
Dim txtSel As TextSelection
Dim strTS As String, strAnswer As String, bIsOpen As Boolean
txtSel = DTE.ActiveDocument.Selection
strTS = txtSel.Text
' Check to see if UndoContext object is already open.
If DTE.UndoContext.IsOpen = True Then
bIsOpen = True
Else
' Open the UndoContext object to track changes.
DTE.UndoContext.Open("RemoveNewLines", False)
End If
MsgBox("Current IsAborted value: " & DTE.UndoContext.IsAborted)
' Perform search for newline characters and remove them.
If strTS <> "" Then
txtSel.Delete()
strTS = Replace(strTS, vbNewLine, "", Compare:=vbTextCompare)
txtSel.Insert(strTS)
End If
' Check to see if you want to discard changes.
strAnswer = MsgBox("Do you want to discard all changes made?", vbYesNo & vbQuestion)
If strAnswer = True Then
DTE.UndoContext.SetAborted()
MsgBox("Current IsAborted value: " & DTE.UndoContext.IsAborted)
End If
' If UndoContext was already open, don't close it.
If bIsOpen = True Then
' Close the UndoContext object to commit the changes.
DTE.UndoContext.Close()
End If
End Sub
Комментарии
Если UndoContext объект отключается SetAborted перед закрытием, все изменения, внесенные в участвующие документы, будут отклонены при UndoContext закрытии объекта.