Glyph.GetHitTest(Point) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Fornece lógica para o teste de sucesso.
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
Parâmetros
- p
- Point
Um ponto para testar em hit-test.
Devoluções
A se o Cursor estiver associado a Glyph; caso contrário, p.null
Exemplos
O exemplo seguinte demonstra como sobrescrever o GetHitTest para ver se o ponto está dentro deste glifo. Este exemplo de código faz parte de um exemplo maior fornecido para a BehaviorService classe.
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
Observações
O GetHitTest método é um abstract método que obriga Glyph as implementações a fornecer lógica de teste de acerto. Em qualquer momento, se o Glyph tiver decidido envolver-se nesse local, terá de devolver um válido Cursor. Caso contrário, voltar null fará com que ignore BehaviorService a localização.