Freigeben über


Glyph.GetHitTest(Point) Methode

Definition

Stellt Treffertestlogik bereit.

public:
 abstract System::Windows::Forms::Cursor ^ GetHitTest(System::Drawing::Point p);
public abstract System.Windows.Forms.Cursor GetHitTest(System.Drawing.Point p);
public abstract System.Windows.Forms.Cursor? GetHitTest(System.Drawing.Point p);
abstract member GetHitTest : System.Drawing.Point -> System.Windows.Forms.Cursor
Public MustOverride Function GetHitTest (p As Point) As Cursor

Parameter

p
Point

Ein Punkt zum Treffertest.

Gibt zurück

ACursor, wenn die Glyph zugeordnet pist ; andernfalls . null

Beispiele

Im folgenden Beispiel wird veranschaulicht, wie Sie die GetHitTest Schreibung außer Kraft setzen, um festzustellen, ob sich der Punkt in dieser Glyphe befindet. Dieses Codebeispiel ist Teil eines größeren Beispiels, das für die BehaviorService Klasse bereitgestellt wird.

public:
    virtual Cursor^ GetHitTest(Point p) override
    {
        // 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 nullptr;
    }
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;
}
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

Hinweise

Die GetHitTest Methode ist eine abstract Methode, mit der Implementierungen erzwungen Glyph werden, um Treffertestlogik bereitzustellen. Wenn sich die Entscheidung, an diesem Glyph Standort beteiligt zu sein, an irgendeinem Punkt beteiligt ist, muss ein gültiger CursorWert zurückgegeben werden. Andernfalls führt die Rückgabe null dazu, dass der BehaviorService Speicherort ignoriert wird.

Gilt für:

Weitere Informationen