gpt4 book ai didi

.net - DoubleClick 事件何时引发,而不是双击鼠标?

转载 作者:行者123 更新时间:2023-12-05 01:26:06 25 4
gpt4 key购买 nike

The documentation for the MouseDoubleClick event

Important

DoubleClick events are logically higher-level events of a control. They may be raised by other user actions, such as shortcut key combinations.

但是,我一直无法找到在未引发 MouseDoubleClick 的情况下引发 DoubleClick 事件的控件,并且 the documentation for DoubleClick event也没有提到任何东西。什么时候使用?

最佳答案

某些情况下您需要鼠标属性(位置、点击...),因此您使用 mousedoubleclicks 事件,在其他情况下您不需要它们,因此系统可以节省一些字节并提高性能。

例如,下面的应用程序几乎是纯 GDI,所以当我单击某个地方时,它非常重要,以至于我拥有鼠标属性...

enter image description here

更新

你是对的:

1:没有引发 doubleclick 和 mousedoubleclick 的情况,反之亦然,因为我反编译了 .Net 3.5 中的控件类,发现唯一引发拖曳事件的地方是在同一个地方 onmouseup 有一些条件:

private void WmMouseUp(ref Message m, MouseButtons button, int clicks)
{
try
{
int x = NativeMethods.Util.SignedLOWORD(m.LParam);
int y = NativeMethods.Util.SignedHIWORD(m.LParam);
Point p = new Point(x, y);
p = this.PointToScreen(p);
if (!this.GetStyle(ControlStyles.UserMouse))
{
this.DefWndProc(ref m);
}
else if (button == MouseButtons.Right)
{
this.SendMessage(0x7b, this.Handle, NativeMethods.Util.MAKELPARAM(p.X, p.Y));
}
bool flag = false;
if ((((this.controlStyle & ControlStyles.StandardClick) == ControlStyles.StandardClick) && this.GetState(0x8000000)) && (!this.IsDisposed && (UnsafeNativeMethods.WindowFromPoint(p.X, p.Y) == this.Handle)))
{
flag = true;
}
if (flag && !this.ValidationCancelled)
{
if (!this.GetState(0x4000000))
{
this.OnClick(new MouseEventArgs(button, clicks, NativeMethods.Util.SignedLOWORD(m.LParam), NativeMethods.Util.SignedHIWORD(m.LParam), 0));
this.OnMouseClick(new MouseEventArgs(button, clicks, NativeMethods.Util.SignedLOWORD(m.LParam), NativeMethods.Util.SignedHIWORD(m.LParam), 0));
}
else
{
this.OnDoubleClick(new MouseEventArgs(button, 2, NativeMethods.Util.SignedLOWORD(m.LParam), NativeMethods.Util.SignedHIWORD(m.LParam), 0));
this.OnMouseDoubleClick(new MouseEventArgs(button, 2, NativeMethods.Util.SignedLOWORD(m.LParam), NativeMethods.Util.SignedHIWORD(m.LParam), 0));
}
}
this.OnMouseUp(new MouseEventArgs(button, clicks, NativeMethods.Util.SignedLOWORD(m.LParam), NativeMethods.Util.SignedHIWORD(m.LParam), 0));
}
finally
{
this.SetState(0x4000000, false);
this.SetState(0x8000000, false);
this.SetState(0x10000000, false);
this.CaptureInternal = false;
}
}

2:如果不存在处理程序,则不调用处理程序调用:

[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnMouseDoubleClick(MouseEventArgs e)
{
MouseEventHandler handler = (MouseEventHandler) base.Events[EventMouseDoubleClick];
if (handler != null)
{
handler(this, e);
}
}

关于.net - DoubleClick 事件何时引发,而不是双击鼠标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9392959/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com