Behavior.OnMouseDoubleClick(Glyph, MouseButtons, Point) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在任何双击消息进入 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当任何双击消息进入 WndProc
的 装饰器窗口的 BehaviorService时,将调用 方法。 消息首先在此处传递到行为堆栈中的最 Behavior 顶层。
true
从此方法返回表示消息已由 Behavior 处理,不应继续处理。 在此处,消息将发送到适当的行为。