HtmlWindow Classe
Definizione
Rappresenta la finestra logica contenente una o più istanze di HtmlDocument.Represents the logical window that contains one or more instances of HtmlDocument.
public ref class HtmlWindow sealed
public sealed class HtmlWindow
type HtmlWindow = class
Public NotInheritable Class HtmlWindow
- Ereditarietà
-
HtmlWindow
Esempio
L'esempio di codice seguente contiene due metodi.The following code example contains two methods. Il primo apre un URL in una finestra denominata displayWindow
, che viene creata con una barra di stato visualizzata.The first opens a URL in a window named displayWindow
, which it creates with a status bar displayed. Il secondo apre un altro URL nella stessa finestra, ma specifica che deve essere visualizzata solo la barra del percorso.The second opens another URL in the same window, but specifies that only the location bar should be displayed. Si noti che le dimensioni della finestra e i controlli visualizzati dipendono dall'URL aperto per primo.Notice that the dimensions of the window and the controls that are displayed depends on which URL is opened first. Per l'esempio di codice è necessario che il form contenga un WebBrowser controllo denominato WebBrowser1
.The code example requires that your form contains a WebBrowser control named WebBrowser1
.
private void DisplayFirstUrl()
{
if (webBrowser1.Document != null)
{
//If this is called first, the window will only have a status bar.
webBrowser1.Document.Window.Open(new Uri("http://www.microsoft.com/"), "displayWindow", "status=yes,width=200,height=400", false);
}
}
private void DisplaySecondUrl()
{
if (webBrowser1.Document != null)
{
// If this is called first, the window will only have an Address bar.
webBrowser1.Document.Window.Open(new Uri("http://msdn.microsoft.com/"), "displayWindow", "width=400,height=200,location=yes", false);
}
}
Private Sub DisplayFirstUrl()
If (WebBrowser1.Document IsNot Nothing) Then
With WebBrowser1.Document
' If this is called first, the window will only have a status bar.
.Window.Open(New Uri("http://www.microsoft.com/"), "displayWindow", "status=yes,width=200,height=400", False)
End With
End If
End Sub
Private Sub DisplaySecondUrl()
If (WebBrowser1.Document IsNot Nothing) Then
With WebBrowser1.Document
' If this is called first, the window will only have an Address bar.
.Window.Open(New Uri("http://msdn.microsoft.com/"), "displayWindow", "width=400,height=200,location=yes", False)
End With
End If
End Sub
Commenti
HtmlWindow non devono essere confusi con il concetto di finestra in Windows Forms o nell'API Windows; non esiste alcuna HWND
risorsa di Windows o simile che corrisponde direttamente a un'istanza di HtmlWindow .HtmlWindow should not be confused with the concept of a window in Windows Forms or the Windows API; there is no HWND
or similar Windows resource that corresponds directly to an instance of HtmlWindow. Fornisce invece HtmlWindow una descrizione di alto livello della posizione di un documento sullo schermo di un utente, nonché i metodi per interagire con gli utenti in base alle richieste e alle finestre di dialogo.Rather, HtmlWindow provides high-level descriptions of a document's location on a user's screen, as well as methods for interacting with users by way of prompts and dialog boxes. HtmlWindow funge da contenitore logico per i documenti di una pagina Web e i relativi metadati, ad esempio la posizione del documento e le funzionalità del Web browser.HtmlWindow acts as a logical container for a Web page's documents and its metadata, such as the document's location and the capabilities of the Web browser.
Una pagina Web è costituita da un singolo documento o da un oggetto FRAMESET
contenente uno o più FRAME
elementi, ognuno dei quali ospita il proprio documento.A Web page consists of a single document, or a FRAMESET
containing one or more FRAME
elements, each of which hosts its own document. Gli sviluppatori Web utilizzano i frame per visualizzare pagine correlate logicamente, ad esempio una pagina di contenuto accanto a una pagina di navigazione.Web developers use framesets to show logically related pages side by side (for example, a content page next to a navigation page). Quando una pagina è costituita da un singolo documento, è possibile accedervi tramite la Document proprietà di HtmlWindow ; se la pagina usa i frame, è possibile accedere ai documenti tramite la Frames raccolta, che è costituita da uno o più HtmlWindow oggetti.When a page consists of a single document, you can access it through the Document property of HtmlWindow; if the page uses frames, you can access their documents through the Frames collection, which consists of one or more HtmlWindow objects.
Quando si ospita il WebBrowser controllo in una Windows Forms Application, è possibile scegliere di interagire con l'utente utilizzando le classi Windows Forms standard, ad esempio Form o MessageBox , oppure è possibile utilizzare i metodi HtmlWindow definiti per questo scopo.When your host the WebBrowser control in a Windows Forms application, you can choose to interact with the user using standard Windows Forms classes, such as Form or MessageBox, or you can use methods on HtmlWindow defined for this purpose. Il Alert metodo presenta una semplice finestra di dialogo con testo personalizzato e un pulsante OK ; Prompt presenta una riga di testo personalizzato e un campo di input di testo per l'utente e Confirm Visualizza una finestra di dialogo con una riga di testo personalizzato e pulsanti OK e Annulla .The Alert method presents a simple dialog box with custom text and an OK button; Prompt presents a line of custom text and a text input field to the user; and Confirm presents a dialog box with a line of custom text and OK and Cancel buttons.
È possibile utilizzare HtmlWindow per aprire nuove finestre contenenti nuovi documenti.You can use HtmlWindow to open new windows containing new documents. Open carica l'URL specificato nella finestra denominata, creandolo se non esiste già, mentre OpenNew apre sempre l'URL in una finestra appena creata.Open loads the specified URL into the named window, creating it if it does not already exist, while OpenNew always opens its URL in a newly created window.
Proprietà
Document |
Ottiene il documento HTML contenuto nella finestra.Gets the HTML document contained within the window. |
DomWindow |
Ottiene l'interfaccia non gestita di cui è stato eseguito il wrapping in questa classe.Gets the unmanaged interface wrapped by this class. |
Frames |
Ottiene un riferimento a ogni elemento |
History |
Ottiene un oggetto contenente gli URL visitati di recente dall'utente.Gets an object containing the user's most recently visited URLs. |
IsClosed |
Ottiene un valore che indica se la finestra è aperta o chiusa.Gets a value indicating whether this window is open or closed. |
Name |
Ottiene o imposta il nome della finestra.Gets or sets the name of the window. |
Opener |
Ottiene un riferimento alla finestra che ha aperto la finestra corrente.Gets a reference to the window that opened the current window. |
Parent |
Ottiene la finestra che si trova al di sopra della finestra corrente in una pagina contenente frame.Gets the window which resides above the current one in a page containing frames. |
Position |
Ottiene la posizione sullo schermo dell'area client della finestra.Gets the position of the window's client area on the screen. |
Size |
Ottiene o imposta la dimensione della finestra corrente.Gets or sets the size of the current window. |
StatusBarText |
Ottiene o imposta il testo visualizzato nella barra di stato di una finestra.Gets or sets the text displayed in the status bar of a window. |
Url |
Ottiene l'URL corrispondente all'elemento corrente visualizzato nella finestra.Gets the URL corresponding to the current item displayed in the window. |
WindowFrameElement |
Ottiene l'elemento frame corrispondente alla finestra corrente.Gets the frame element corresponding to this window. |
Metodi
Alert(String) |
Visualizza una finestra di messaggio.Displays a message box. |
AttachEventHandler(String, EventHandler) |
Aggiunge un gestore eventi per l'evento HTML DOM specificato.Adds an event handler for the named HTML DOM event. |
Close() |
Chiude la finestra.Closes the window. |
Confirm(String) |
Visualizza una finestra di dialogo con un messaggio e i pulsanti Yes e No.Displays a dialog box with a message and buttons to solicit a yes/no response. |
DetachEventHandler(String, EventHandler) |
Rimuove il gestore eventi specificato.Removes the named event handler. |
Equals(Object) |
Verifica l'uguaglianza dell'oggetto relativamente a quello corrente.Tests the object for equality against the current object. |
Focus() |
Assegna lo stato attivo alla finestra corrente.Puts the focus on the current window. |
GetHashCode() |
Svolge una funzione hash per un tipo particolare.Serves as a hash function for a particular type. |
GetType() |
Ottiene l'oggetto Type dell'istanza corrente.Gets the Type of the current instance. (Ereditato da Object) |
MemberwiseClone() |
Crea una copia superficiale dell'oggetto Object corrente.Creates a shallow copy of the current Object. (Ereditato da Object) |
MoveTo(Int32, Int32) |
Sposta la finestra in corrispondenza delle coordinate specificate sullo schermo.Moves the window to the specified coordinates on the screen. |
MoveTo(Point) |
Sposta la finestra in corrispondenza delle coordinate specificate sullo schermo.Moves the window to the specified coordinates on the screen. |
Navigate(String) |
Visualizza o scarica il nuovo contenuto disponibile nell'URL specificato.Displays or downloads the new content located at the specified URL. |
Navigate(Uri) |
Visualizza un nuovo documento nella finestra corrente.Displays a new document in the current window. |
Open(String, String, String, Boolean) |
Visualizza un file nella finestra specificata.Displays a file in the named window. |
Open(Uri, String, String, Boolean) |
Visualizza un file nella finestra specificata.Displays a file in the named window. |
OpenNew(String, String) |
Visualizza un file in una nuova finestra.Displays a file in a new window. |
OpenNew(Uri, String) |
Visualizza un file in una nuova finestra.Displays a file in a new window. |
Prompt(String, String) |
Visualizza all'utente una finestra di dialogo in cui sono contenuti un messaggio e una casella di testo.Shows a dialog box that displays a message and a text box to the user. |
RemoveFocus() |
Rimuove lo stato attivo dalla finestra corrente.Takes focus off of the current window. |
ResizeTo(Int32, Int32) |
Modifica la dimensione della finestra in base alle dimensioni specificate.Changes the size of the window to the specified dimensions. |
ResizeTo(Size) |
Modifica la dimensione della finestra in base alle dimensioni specificate.Changes the size of the window to the specified dimensions. |
ScrollTo(Int32, Int32) |
Scorre la finestra fino alla posizione designata.Scrolls the window to the designated position. |
ScrollTo(Point) |
Sposta la finestra in corrispondenza delle coordinate specificate.Moves the window to the specified coordinates. |
ToString() |
Restituisce una stringa che rappresenta l'oggetto corrente.Returns a string that represents the current object. (Ereditato da Object) |
Operatori
Equality(HtmlWindow, HtmlWindow) |
Verifica l'uguaglianza dei due oggetti HtmlWindow.Tests the two HtmlWindow objects for equality. |
Inequality(HtmlWindow, HtmlWindow) |
Verifica la disuguaglianza dei due oggetti |
Eventi
Error |
Si verifica in caso di errore di runtime in uno script in esecuzione all'interno della finestra.Occurs when script running inside of the window encounters a run-time error. |
GotFocus |
Si verifica quando la finestra corrente riceve lo stato attivo per l'input dell'utente.Occurs when the current window obtains user input focus. |
Load |
Si verifica quando il documento della finestra e tutti i relativi elementi sono stati inizializzati.Occurs when the window's document and all of its elements have finished initializing. |
LostFocus |
Si verifica quando la finestra ha perso lo stato attivo per l'input dell'utente.Occurs when user input focus has left the window. |
Resize |
Si verifica quando l'utente usa il mouse per modificare le dimensioni della finestra.Occurs when the user uses the mouse to change the dimensions of the window. |
Scroll |
Si verifica quando l'utente scorre la finestra per visualizzare il testo non presente sullo schermo.Occurs when the user scrolls through the window to view off-screen text. |
Unload |
Si verifica quando è in corso lo scaricamento della pagina corrente e sta per essere visualizzata una nuova pagina.Occurs when the current page is unloading, and a new page is about to be displayed. |