Glyph.GetHitTest(Point) Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Biedt testlogica voor treffers.
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
Parameters
- p
- Point
Een punt om te testen.
Retouren
A Cursor als de Glyph is gekoppeld aanp; anders. null
Voorbeelden
In het volgende voorbeeld ziet u hoe u het GetHitTest overschrijvingspunt overschrijft om te zien of het punt zich binnen dit symbool bevindt. Dit codevoorbeeld maakt deel uit van een groter voorbeeld voor de BehaviorService klasse.
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
Opmerkingen
De GetHitTest methode is een abstract methode die implementaties dwingt Glyph om hittestlogica te bieden. Als de Glyph locatie op een gegeven moment heeft besloten betrokken te worden, moet er een geldige Cursorlocatie worden geretourneerd. Als u dit niet doet, null wordt de BehaviorService locatie genegeerd.