UndoContext.Open メソッド

更新 : 2007 年 11 月

元に戻す操作を新たに開始します。

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

構文

'宣言
Sub Open ( _
    Name As String, _
    Strict As Boolean _
)
'使用
Dim instance As UndoContext
Dim Name As String
Dim Strict As Boolean

instance.Open(Name, Strict)
void Open(
    string Name,
    bool Strict
)
void Open(
    [InAttribute] String^ Name, 
    [InAttribute] bool Strict
)
function Open(
    Name : String, 
    Strict : boolean
)

パラメータ

  • Name
    型 : System.String

    必ず指定します。元に戻すコンテキストを提供するプロシージャの名前。

  • Strict
    型 : System.Boolean

    省略可能です。元に戻すスタックのリンケージが厳密かどうかを示します。既定値は Falseです。

解説

Open メソッドを実行しているときに UndoContext オブジェクトが既に開かれている場合は、エラーが発生します。

Sub OpenExample()
   ' Before running, select text in an open document.
   Dim txtSel As TextSelection
   Dim strTS As String, boolWasOpen As Boolean
   txtSel = DTE.ActiveDocument.Selection
   strTS = txtSel.Text

   ' Check to see if UndoContext object is already open.
   If DTE.UndoContext.IsOpen = True Then
      boolWasOpen = True
   Else
      ' Open the UndoContext object to track changes.
      DTE.UndoContext.Open("RemoveNewLines", False)
   End If

   ' Perform search for newline characters and remove them.
   If strTS <> "" Then
      txtSel.Delete()
      strTS = Replace(strTS, vbNewLine, "", Compare:=vbTextCompare)
      txtSel.Insert(strTS)
   End If

   ' If UndoContext was already open, don't close it.
   If boolWasOpen = False Then
      ' Close the UndoContext object to commit the changes.
      DTE.UndoContext.Close()
   End If
End Sub

アクセス許可

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

参照

参照

UndoContext インターフェイス

UndoContext メンバ

EnvDTE 名前空間