Glyph.GetHitTest メソッドとは? わかりやすく解説

Glyph.GetHitTest メソッド

メモ : このメソッドは、.NET Framework version 2.0 で新しく追加されたものです。

ヒット テストのロジックを提供します。

名前空間: System.Windows.Forms.Design.Behavior
アセンブリ: System.Design (system.design.dll 内)
構文構文

Public MustOverride Function
 GetHitTest ( _
    p As Point _
) As Cursor
public abstract Cursor GetHitTest (
    Point p
)
public:
virtual Cursor^ GetHitTest (
    Point p
) abstract
public abstract Cursor GetHitTest (
    Point p
)

パラメータ

p

ヒット テストを行うポイント。

戻り値
Glyph が p に関連付けられている場合は Cursor。それ以外の場合は null 参照 (Visual Basic では Nothing)。

解説解説

GetHitTest メソッドは、ヒット テスト ロジックを提供するための Glyph が実装された abstract メソッドです。任意のポイントを指定したときに、Glyph がその位置に置かれるように設定されている場合は、有効な Cursor を返す必要があります。それ以外の場合は null 参照 (Visual Basic では Nothing) が返され、BehaviorService はその位置を無視します。

使用例使用例

GetHitTest をオーバーライドしてポイントがこのグリフ内にあるかどうか調べる方法を次の例に示します。このコード例は、BehaviorService クラスのトピックで取り上げているコード例の一部分です。

Public Overrides Function
 GetHitTest(ByVal p As Point) As
 Cursor
    ' GetHitTest is called to see if the point is
    ' within this glyph.  This gives us a chance to decide
    ' what cursor to show.  Returning null from here means
    ' the mouse pointer is not currently inside of the glyph.
    ' Returning a valid cursor here indicates the pointer is
    ' inside the glyph,and also enables our Behavior property
    ' as the active behavior.
    If Bounds.Contains(p) Then
        Return Cursors.Hand
    End If

    Return Nothing

End Function
public override Cursor GetHitTest(Point p)
{
    // GetHitTest is called to see if the point is
    // within this glyph.  This gives us a chance to decide
    // what cursor to show.  Returning null from here means
    // the mouse pointer is not currently inside of the glyph.
    // Returning a valid cursor here indicates the pointer is
    // inside the glyph, and also enables our Behavior property
    // as the active behavior.
    if (Bounds.Contains(p))
    {
        return Cursors.Hand;
    }

    return null;
}
.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

Glyph.GetHitTest メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Glyph.GetHitTest メソッドのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS