다음을 통해 공유


Behavior.OnMouseDoubleClick(Glyph, MouseButtons, Point) 메서드

정의

BehaviorService의 표시기 창에 두 번 클릭 메시지가 전달될 때 호출됩니다.

public:
 virtual bool OnMouseDoubleClick(System::Windows::Forms::Design::Behavior::Glyph ^ g, System::Windows::Forms::MouseButtons button, System::Drawing::Point mouseLoc);
public virtual bool OnMouseDoubleClick (System.Windows.Forms.Design.Behavior.Glyph g, System.Windows.Forms.MouseButtons button, System.Drawing.Point mouseLoc);
public virtual bool OnMouseDoubleClick (System.Windows.Forms.Design.Behavior.Glyph? g, System.Windows.Forms.MouseButtons button, System.Drawing.Point mouseLoc);
abstract member OnMouseDoubleClick : System.Windows.Forms.Design.Behavior.Glyph * System.Windows.Forms.MouseButtons * System.Drawing.Point -> bool
override this.OnMouseDoubleClick : System.Windows.Forms.Design.Behavior.Glyph * System.Windows.Forms.MouseButtons * System.Drawing.Point -> bool
Public Overridable Function OnMouseDoubleClick (g As Glyph, button As MouseButtons, mouseLoc As Point) As Boolean

매개 변수

button
MouseButtons

클릭한 단추를 나타내는 MouseButtons 값입니다.

mouseLoc
Point

마우스 클릭이 발생한 위치입니다.

반환

메시지가 처리되었으면 true이고, 처리되지 않았으면 false입니다.

예제

다음 코드 예제에서는 두 번 클릭 메시지를 처리 하는 방법을 보여 줍니다. 전체 코드 목록은 방법: 디자인 모드에서 컨트롤의 모양 및 동작 확장을 참조하세요.

// When you double-click on an AnchorGlyph, the value of 
// the control's Anchor property is toggled.
//
// Note that the value of the Anchor property is not set
// by direct assignment. Instead, the 
// PropertyDescriptor.SetValue method is used. This 
// enables notification of the design environment, so 
// related events can be raised, for example, the
// IComponentChangeService.ComponentChanged event.

public override bool OnMouseDoubleClick(
    Glyph g, 
    MouseButtons button, 
    Point mouseLoc)
{
    base.OnMouseDoubleClick(g, button, mouseLoc);

    if (button == MouseButtons.Left)
    {
        AnchorGlyph ag = g as AnchorGlyph;
        PropertyDescriptor pdAnchor = 
            TypeDescriptor.GetProperties(ag.relatedControl)["Anchor"];

        if (ag.IsEnabled)
        {
            // The glyph is enabled. 
            // Clear the AnchorStyle flag to disable the Glyph.
            pdAnchor.SetValue(
                ag.relatedControl, 
                ag.relatedControl.Anchor ^ ag.anchorStyle );
        }
        else
        {
            // The glyph is disabled. 
            // Set the AnchorStyle flag to enable the Glyph.
            pdAnchor.SetValue(
                ag.relatedControl,
                ag.relatedControl.Anchor | ag.anchorStyle);
        }
    }

    return true;
}
' When you double-click on an AnchorGlyph, the value of 
' the control's Anchor property is toggled.
'
' Note that the value of the Anchor property is not set
' by direct assignment. Instead, the 
' PropertyDescriptor.SetValue method is used. This 
' enables notification of the design environment, so 
' related events can be raised, for example, the
' IComponentChangeService.ComponentChanged event.
Public Overrides Function OnMouseDoubleClick( _
ByVal g As Glyph, _
ByVal button As MouseButtons, _
ByVal mouseLoc As Point) As Boolean

    MyBase.OnMouseDoubleClick(g, button, mouseLoc)

    If button = MouseButtons.Left Then
        Dim ag As AnchorGlyph = g

        Dim pdAnchor As PropertyDescriptor = _
        TypeDescriptor.GetProperties(ag.relatedControl)("Anchor")

        If ag.IsEnabled Then
            ' The glyph is enabled. 
            ' Clear the AnchorStyle flag to disable the Glyph.
            pdAnchor.SetValue(ag.relatedControl, _
            ag.relatedControl.Anchor Xor ag.anchorStyle)
        Else
            ' The glyph is disabled. 
            ' Set the AnchorStyle flag to enable the Glyph.
            pdAnchor.SetValue(ag.relatedControl, _
            ag.relatedControl.Anchor Or ag.anchorStyle)
        End If
    End If

    Return True

End Function

설명

메서드는 OnMouseDoubleClick 두 번 클릭 메시지가 의 표시기 창의 를 입력할 때 호출됩니다 WndProcBehaviorService. 이 메시지는 먼저 동작 스택의 맨 위에 Behavior 전달됩니다. 이 메서드에서 반환은 true 에서 메시지를 처리했으며 계속 처리 Behavior 해서는 안 됨을 의미합니다. 여기에서 메시지가 적절한 동작으로 전송됩니다.

적용 대상

추가 정보