Share via


UndoContext.SetAborted 메서드

UndoContext 개체를 연 후 열려 있는 문서에서 수행한 모든 변경 내용을 취소합니다.

네임스페이스:  EnvDTE
어셈블리:  EnvDTE(EnvDTE.dll)

구문

‘선언
Sub SetAborted
void SetAborted()
void SetAborted()
abstract SetAborted : unit -> unit 
function SetAborted()

설명

SetAborted는 열린 UndoContext 개체의 IsAborted 속성을 true로 설정합니다. 이렇게 되면 UndoContext 개체를 연 이후에 UndoContext 개체를 닫을 때까지 관련 문서에 대해 수행된 모든 변경 내용이 취소됩니다.

예제

Sub SetAbortedExample()
   ' 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

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

UndoContext 인터페이스

EnvDTE 네임스페이스