マウスのプロパティ(場所、クリックなど)が必要な場合もありますので、mousedoubleclicksイベントを使用する必要があります。必要がない場合は、システムによってバイト数が節約され、パフォーマンスが向上します。
:doubleclickが発生し、mousedoubleclickが発生しているケースはありません。私は.NET 3.5でコントロールクラスを逆コンパイル、およびいくつかの条件付きonMouseUpの同じ場所にある事象が発生している牽引だけの場所を見つけたのでERSA、:
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;
}
}
:ハンドラ呼び出しは呼び出されませんハンドラが存在しない場合:
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnMouseDoubleClick(MouseEventArgs e)
{
MouseEventHandler handler = (MouseEventHandler) base.Events[EventMouseDoubleClick];
if (handler != null)
{
handler(this, e);
}
}
クリックすると、スペースバーを押してボタンをクリックできます。コントロールがあらゆる種類の入力イベントでOnDoubleClickを呼び出すことは許可されていますが、必ずしもそれが意味をなさないとは限りません。 –
@HansPassant私が知っているところでは、Enterを押すことは、例として 'MouseClick'のドキュメンテーションとして与えられています。 'OnDoubleClick'が意味を成すいくつかの状況が想像できます。一つは' ListView'でEnterを押すことです。しかし、私が思いつくことができるものでは、実際には起こりません。 – hvd
標準の.NETコントロールはこれを行いません。そこにある何万もの他のものについて話すことはできません。 –