HtmlWindow.GotFocus HtmlWindow.GotFocus HtmlWindow.GotFocus HtmlWindow.GotFocus Event

定義

現在のウィンドウがユーザーの入力フォーカスを得ると発生します。Occurs when the current window obtains user input focus.

public:
 event System::Windows::Forms::HtmlElementEventHandler ^ GotFocus;
public event System.Windows.Forms.HtmlElementEventHandler GotFocus;
member this.GotFocus : System.Windows.Forms.HtmlElementEventHandler 
Public Custom Event GotFocus As HtmlElementEventHandler 

このメンバーの使用例を次のコード例に示します。The following code example demonstrates the use of this member. この例では、イベントハンドラーがGotFocusイベントの発生を報告します。In the example, an event handler reports on the occurrence of the GotFocus event. このレポートは、イベントがいつ発生し、デバッグに役立つかを理解するのに役立ちます。This report helps you to learn when the event occurs and can assist you in debugging.

コード例を実行するには、という名前HtmlWindow HtmlWindow1の型のインスタンスを含むプロジェクトに貼り付けます。To run the example code, paste it into a project that contains an instance of type HtmlWindow named HtmlWindow1. 次に、イベントハンドラーがGotFocusイベントに関連付けられていることを確認します。Then ensure that the event handler is associated with the GotFocus event.

private void HtmlWindow1_GotFocus(Object sender, HtmlElementEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "MouseButtonsPressed", e.MouseButtonsPressed );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ClientMousePosition", e.ClientMousePosition );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "OffsetMousePosition", e.OffsetMousePosition );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "MousePosition", e.MousePosition );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "BubbleEvent", e.BubbleEvent );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "KeyPressedCode", e.KeyPressedCode );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "AltKeyPressed", e.AltKeyPressed );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "CtrlKeyPressed", e.CtrlKeyPressed );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ShiftKeyPressed", e.ShiftKeyPressed );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "EventType", e.EventType );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ReturnValue", e.ReturnValue );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "FromElement", e.FromElement );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ToElement", e.ToElement );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "GotFocus Event" );
}
Private Sub HtmlWindow1_GotFocus(sender as Object, e as HtmlElementEventArgs) _ 
     Handles HtmlWindow1.GotFocus

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "MouseButtonsPressed", e.MouseButtonsPressed)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ClientMousePosition", e.ClientMousePosition)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "OffsetMousePosition", e.OffsetMousePosition)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "MousePosition", e.MousePosition)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "BubbleEvent", e.BubbleEvent)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "KeyPressedCode", e.KeyPressedCode)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "AltKeyPressed", e.AltKeyPressed)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "CtrlKeyPressed", e.CtrlKeyPressed)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ShiftKeyPressed", e.ShiftKeyPressed)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "EventType", e.EventType)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ReturnValue", e.ReturnValue)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "FromElement", e.FromElement)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ToElement", e.ToElement)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"GotFocus Event")

End Sub

注釈

GotFocus次の場合に発生します。GotFocus will occur for:

  • 最初のFRAMESET FRAMESET読み込み時の内の最初のウィンドウ。The first window in a FRAMESET when the FRAMESET first loads.

  • コントロールをWebBrowser含むウィンドウを前面に移動したときに最後にフォーカスFRAMEがあった。The FRAME that last had focus when the window containing the WebBrowser control is brought to the foreground.

  • ユーザー FRAMEがクリックしたのが、ウィンドウ内の要素にフォーカスを移動していない場合にのみ表示されます。A FRAME clicked by the user, but only if the user's click does not put focus on an element within the window.

GotFocusイベントの既定のアクションをキャンセルしたり、バブルから除外したりすることはできません。You cannot cancel the default action for the GotFocus event, or prevent it from bubbling.

適用対象

こちらもご覧ください