windows 鼠标单击是 WM_* 消息还是向上和向下消息的组合?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1440515/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 13:09:27  来源:igfitidea点击:

Is a mouse click a WM_* message or a combination of up & down messages?

windowsmousewindows-messages

提问by James Cadd

I'm used to working with a Windows framework that provides events for things like a mouse click or a mouse double click. Are click events a Windows construct (i.e. does Windows send a WM_DOUBLECLICK or similar message) or does it send WM_MOUSEDOWN and WM_MOUSEUP to applications which then do some math to decide if the event was a click or otherwise?

我习惯于使用为鼠标单击或鼠标双击等事件提供事件的 Windows 框架。单击事件是 Windows 构造(即 Windows 是否发送 WM_DOUBLECLICK 或类似消息),还是将 WM_MOUSEDOWN 和 WM_MOUSEUP 发送到应用程序,然后应用程序进行一些数学运算以确定事件是单击还是其他?

回答by Ben S

According to MSDN documentationThe correct order of messages you will see for double click event are - WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBLCLK, and WM_LBUTTONUP

根据MSDN 文档,您将看到的双击事件的正确消息顺序是 - WM_LBUTTONDOWN、WM_LBUTTONUP、WM_LBUTTONDBLCLK 和 WM_LBUTTONUP

回答by Ken White

It's a combination of messages sent through the WindowProc(). The messages are WM_LBUTTONDOWN, WM_LBUTTONDBLCLK, WM_LBUTTONUP for the left mouse button, WM_MBUTTONDOWN and so forth for the middle button, and WM_RBUTTONDOWN and so forth for the right mouse button. See the Windows SDK at MSDNfor more info.

它是通过 WindowProc() 发送的消息的组合。消息是 WM_LBUTTONDOWN、WM_LBUTTONDBLCLK、WM_LBUTTONUP 用于鼠标左键,WM_MBUTTONDOWN 等用于中键,WM_RBUTTONDOWN 等用于鼠标右键。有关详细信息,请参阅MSDN 上的 Windows SDK 。

回答by xamid

A mouse click is not a combination of windows messages, but it can lead to, depending on the application that is clicked. There is a huge difference between windows input and windows messages, as they are only a tool for some applications, used in many different ways, as explained on MSDN:

鼠标单击不是 Windows 消息的组合,但它可能导致,具体取决于单击的应用程序。Windows 输入和 Windows 消息之间存在巨大差异,因为它们只是某些应用程序的工具,以多种不同方式使用,如 MSDN 上所述:

I also provided an example that shows the difference clearly in my question How could it work to use multiple cursors on one Windows client?It shows what messages are sent by clicking and that windows messages are often not enough to emulate a mouse click, but if they are, how they can be used.

我还提供了一个示例,在我的问题中清楚地显示了差异,在一个 Windows 客户端上使用多个游标如何工作?它显示了通过单击发送了什么消息,Windows 消息通常不足以模拟鼠标单击,但如果是,则如何使用它们。