Partager via


Behavior.OnMouseDoubleClick(Glyph, MouseButtons, Point) Méthode

Définition

Appelé lorsqu'un message de double-clic entre dans la fenêtre de dispositif d'ornement du 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

Paramètres

button
MouseButtons

Valeur MouseButtons qui indique le bouton qui a fait l'objet d'un clic.

mouseLoc
Point

L'emplacement auquel le clic s'est produit.

Retours

Boolean

true si le message a été géré ; sinon, false.

Exemples

L’exemple de code suivant montre comment gérer un message en double-clic. Pour obtenir une liste de codes complète, consultez Guide pratique pour étendre l’apparence et le comportement des contrôles en mode Création.

// 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

Remarques

La OnMouseDoubleClick méthode est appelée quand un message double-clic entre dans la WndProc fenêtre d’ornement du BehaviorService. Le message est d’abord passé ici, au plus Behavior haut dans la pile de comportements. Le retour true de cette méthode signifie que le message a été géré par le Behavior message et ne doit pas continuer à être traité. À partir de là, le message est envoyé au comportement approprié.

S’applique à

Voir aussi