HTMLWindow.CurrentTabObject 属性
获取 HTML 编辑窗口中的**“源”或“设计器”**选项卡的状态(活动或非活动)。
命名空间: EnvDTE
程序集: EnvDTE(在 EnvDTE.dll 中)
语法
声明
ReadOnly Property CurrentTabObject As Object
Object CurrentTabObject { get; }
property Object^ CurrentTabObject {
Object^ get ();
}
abstract CurrentTabObject : Object
function get CurrentTabObject () : Object
属性值
类型:System.Object
一个对象。
备注
如果 HTML 编辑窗口中的当前选项卡是**“源”选项卡,则返回的对象是 TextWindow 对象。如果当前选项卡是“设计”**选项卡,则返回的对象是 IHTMLDocument2 对象。
示例
Sub CurrentTabObjectExample (ByVal dte As EnvDTE.DTE)
' Open an HTML document before running this sample.
If TypeOf dte.ActiveDocument.ActiveWindow.Object Is HTMLWindow Then
' Ask the user for a file to insert into the body of the HTML
' document. This file should be an HTML fragment.
Dim strFile As String = InputBox("Enter the name of a file to _
insert at the end of the HTML document:")
' Get the HTMLWindow object and determine which tab is
' currently active.
Dim objHTMLWin As HTMLWindow = _
dte.ActiveDocument.ActiveWindow.Object
Dim Tab As vsHTMLTabs = objHTMLWin.CurrentTab
' Switch to the "source" tab.
objHTMLWin.CurrentTab = vsHTMLTabs.vsHTMLTabsSource
' Get an EditPoint at the start of the text.
Dim objTextWin As TextWindow = objHTMLWin.CurrentTabObject
Dim objEP As EditPoint = _
objTextWin.ActivePane.StartPoint.CreateEditPoint
' Look for the end of the document body.
If objEP.FindPattern("</body>") Then
' Insert the contents of the file.
objEP.InsertFromFile(strFile)
End If
' Switch back to the original view of the HTML file.
objHTMLWin.CurrentTab = Tab
Else
MsgBox("You must open an HTML document.")
End If
End Sub
public void CurrentTabObjectExample(_DTE dte)
{
// Open an HTML document before running this sample.
if (dte.ActiveDocument.ActiveWindow.Object is HTMLWindow)
{
HTMLWindow objHTMLWin;
vsHTMLTabs Tab;
String strFileName;
// Ask the user for a file to insert into the body of the HTML
// document. This file should be an HTML fragment.
strFileName = Microsoft.VisualBasic.Interaction.InputBox
("Enter the name of a file to insert at the end of the HTML
document:","","",100,100);
// Get the HTMLWindow object and determine which tab is
// currently active.
objHTMLWin = dte.ActiveDocument.ActiveWindow.Object as
HTMLWindow;
Tab = objHTMLWin.CurrentTab;
// Switch to the "source" tab.
objHTMLWin.CurrentTab = vsHTMLTabs.vsHTMLTabsSource;
// Get an EditPoint at the start of the text.
TextWindow objTextWin;
EditPoint ep;
EditPoint ep2 = null;
TextRanges textRanges = null;
objTextWin = objHTMLWin.CurrentTabObject as TextWindow;
ep = objTextWin.ActivePane.StartPoint.CreateEditPoint();
textRanges = objTextWin.Selection.TextRanges;
// Look for the end of the document body.
if (ep.FindPattern
("</body>",(int)vsFindOptions.vsFindOptionsNone, ref ep2, ref
textRanges))
// Insert the contents of the file.
ep.InsertFromFile (strFileName);
// Switch back to the original view of the HTML file.
objHTMLWin.CurrentTab = Tab;
}
else
MessageBox.Show ("You must open an HTML document.");
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。