次の方法で共有


UndoContext.SetAborted メソッド

更新 : 2007 年 11 月

UndoContext オブジェクトを開いた後に行われた、現在開かれている対象ドキュメントに対するすべての変更を破棄します。

名前空間 :  EnvDTE
アセンブリ :  EnvDTE (EnvDTE.dll 内)

構文

'宣言
Sub SetAborted
'使用
Dim instance As UndoContext

instance.SetAborted()
void SetAborted()
void SetAborted()
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

アクセス許可

  • 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

UndoContext インターフェイス

UndoContext メンバ

EnvDTE 名前空間