简体   繁体   English

当用户单击禁用的窗口(通过 EnableWindow(hwnd, FALSE) 禁用)时,如何以编程方式阻止 Windows 播放“默认提示音”声音?

[英]How to programatically hinder Windows from playing "Default Beep" sound when user clicks on disabled window (disabled via EnableWindow(hwnd, FALSE))?

When a window is disabled via EnableWindow(hwnd, FALSE), and the user clicks on it, then the "Default Beep" sound gets played.当通过 EnableWindow(hwnd, FALSE) 禁用窗口时,用户单击它,然后播放“默认哔哔声”声音。 I don't want this to happen.我不希望这种情况发生。 How can I disable this behavior programatically for the current Process in C/C++ with Win32 code?如何使用 Win32 代码以编程方式为 C/C++ 中的当前进程禁用此行为?

The beep is generated by the default window processing of the WM_SETCURSOR message.哔声是由WM_SETCURSOR消息的默认窗口处理生成的。

From docs for WM_SETCURSOR :来自WM_SETCURSOR 的文档:

If the low-order word of the lParam parameter is HTERROR and the high-order word of lParam specifies that one of the mouse buttons is pressed, DefWindowProc calls the MessageBeep function.如果 lParam 参数的低位字是 HTERROR 并且 lParam 的高位字指定按下鼠标按钮之一,DefWindowProc 调用 MessageBeep 函数。

To prevent the beep, your window procedure should handle WM_SETCURSOR and not call DefWindowProc under those conditions.为了防止发出哔哔声,您的窗口过程应该处理WM_SETCURSOR而不是在这些条件下调用DefWindowProc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM