Glyph.GetHitTest(Point) 메서드

정의

적중 테스트 논리를 제공합니다.

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

매개 변수

p
Point

적중 테스트 지점입니다.

반품

A 가 연결되어 있으면 이고 , 그렇지 않으면 .

예제

다음 예제에서는 점이 이 문자 모양 내에 있는지 확인하기 위해 재정 GetHitTest 의하는 방법을 보여 줍니다. 이 코드 예제는 클래스에 제공된 더 큰 예제의 BehaviorService 일부입니다.

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

설명

GetHitTest 메서드는 구현이 적중 테스트 논리를 제공하도록 강제 abstract 하는 메서드입니다Glyph. 어느 시점이라도 해당 위치에 관여하기로 결정한 경우 Glyph 유효한 Cursor위치를 반환해야 합니다. 그렇지 않으면 반환하면 null 위치가 BehaviorService 무시됩니다.

적용 대상

추가 정보