HTMLWindow3 介面
表示在 Visual Studio 整合式開發環境 (IDE) 中的 HTML 文件視窗。
命名空間: EnvDTE90
組件: EnvDTE90 (在 EnvDTE90.dll 中)
語法
'宣告
<GuidAttribute("BAD0A3DD-8109-4684-B806-A5282267BFE4")> _
Public Interface HTMLWindow3
[GuidAttribute("BAD0A3DD-8109-4684-B806-A5282267BFE4")]
public interface HTMLWindow3
[GuidAttribute(L"BAD0A3DD-8109-4684-B806-A5282267BFE4")]
public interface class HTMLWindow3
[<GuidAttribute("BAD0A3DD-8109-4684-B806-A5282267BFE4")>]
type HTMLWindow3 = interface end
public interface HTMLWindow3
HTMLWindow3 型別會公開下列成員。
屬性
名稱 | 說明 | |
---|---|---|
CurrentPane | 取得或設定目前 [HTML 編輯器] 視窗類型。 | |
CurrentView | 取得或設定 [HTML 編輯器] 視窗是位於 [來源]、[設計工具] 還是 [分割] 檢視中。 |
回頁首
方法
名稱 | 說明 | |
---|---|---|
WaitForBackgroundProcessingComplete | 暫停執行程式,直到背景處理完畢為止。 |
回頁首
備註
當文件為 HTML 文件時,Window 物件的 Object 屬性會傳回 HTMLWindow3。 CurrentTab 屬性設定為 vsHTMLTabsSource 時,Window.Selection 和 Document.Selection 會傳回 TextSelection 物件。
在 Visual Studio 2008 HTML 編輯器中加入 [分割] 檢視時,已一併加入 HTMLWindow3、vsHTMLPanes 和 vsHTMLViews。 [分割] 檢視會區隔 [HTML 編輯器] 視窗的索引標籤和檢視項目。 切換檢視 (切換至 [設計] 或 [原始碼]) 不一定就是切換索引標籤 (切換至 [設計] / [分割] / [原始碼])。 例如,當您按一下 [分割] 索引標籤時,在 [設計] 和 [來源] 之間切換檢視並不會變更該索引標籤,只會啟動或停用 [分割] 索引標籤中的 [設計] 和 [來源] 部分。
Visual Studio 2008 HTMLWindow 物件現在也會實作 HTMLWindow3 介面,這個介面會傳回目前檢視 ([設計] 或 [來源]) 和目前窗格 ([設計]、[來源] 或 [分割] 索引標籤)。
HTMLWindow3 規則
HTMLWindow3 的行為是:
Get
目前窗格 (索引標籤) |
目前檢視會傳回 |
---|---|
vsHTMLViewDesign 或 vsHTMLViewSource,視目前正在使用哪個部分而定。 |
Set
目前窗格 (索引標籤) |
設定 |
---|---|
|
|
|
|
|
範例
Sub HTMLWindow3Example(ByVal dte As EnvDTE80.DTE2)
' Open an HTML document before running this sample.
If TypeOf dte.ActiveDocument.ActiveWindow.Object Is HTMLWindow3 _
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 HTMLWindow3 object and determine which tab is
' currently active.
Dim objHTMLWin As HTMLWindow3 = _
CType(dte.ActiveDocument.ActiveWindow.Object, HTMLWindow3)
Dim Tab As vsHTMLTabs = CType(objHTMLWin.CurrentTab, _
vsHTMLTabs)
Dim cpane As vsHTMLPanes = vsHTMLPanes.vsHTMLPaneSplit
' Switch to the "split" view, source view.
objHTMLWin.CurrentPane = vsHTMLPanes.vsHTMLPaneSplit
objHTMLWin.CurrentView = vsHTMLViews.vsHTMLViewSource
' Get an EditPoint at the start of the text.
Dim objTextWin As TextWindow = _
CType(objHTMLWin.CurrentTabObject, TextWindow)
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 HTMLWindowExample(_DTE dte)
{
// Open an HTML document before running this sample.
if (dte.ActiveDocument.ActiveWindow.Object is HTMLWindow3)
{
HTMLWindow3 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 HTMLWindow3 object and determine which tab is
// currently active.
objHTMLWin = dte.ActiveDocument.ActiveWindow.Object as
HTMLWindow3;
Tab = objHTMLWin.CurrentTab;
// Switch to the "source" tab.
objHTMLWin.CurrentPane = vsHTMLPanes.vsHTMLPaneSplit;
objHTMLWin.CurrentTab = vsHTMLViews.vsHTMLViewSource;
// 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.");
}