如何禁用Alt键的正常行为? [英] How to disable normal behaviour of Alt key?
问题描述
通常Alt键打开的菜单在Windows中。
Normally the Alt key opens the menu in Windows.
我需要这个被禁用,因为我需要为我的应用程序Alt键。 (这是旧电脑的模拟器,所以我要模仿它的行为。)我把它写在纯粹的Windows API,所以我希望,必须有一些消息被发送,需要被禁止,丢弃或忽略。
I need this to be disabled, because I need Alt key for my application. (It is an emulator of old computer, so I need to mimic its behaviour.) I write it in pure Windows API, so I expect there must be some message which is sent and needs to be disabled, discarded or ignored.
Alt + Tab是没有问题的,以及其他系统键和组合键,我只需要当它打开的菜单忽略Alt键。
Alt+Tab is no problem, as well as other system keys and key combinations, I just need to ignore Alt when it opens the menu.
(我的应用程序使用DirectInput的读取钥匙,所以效果很好。我只需要禁用它打开与Alt键菜单的功能。我会用鼠标打开菜单。)
(My application uses DirectInput to read the keys, so it works well. I just need to disable the functionality which opens the menu with Alt key. I will open the menu using mouse.)
推荐答案
如何检查 WM_SYSCOMMAND
,当wParam为 SC_KEYMENU
,返回0?
How about checking for WM_SYSCOMMAND
, and when wParam is SC_KEYMENU
, return 0?
更新/精确解:
if(wParam==SC_KEYMENU && (lParam>>16)<=0) return 0;
return DefWindowProc(hwnd, message, wParam, lParam);
描述:如果 lParam的&GT;&GT; 16
是正的,那么菜单被鼠标激活,当它是零或负数,菜单由Alt键或Alt +东西激活。
Description: If lParam>>16
is positive then menu is activated by mouse, when it is zero or negative then menu is activated by Alt or Alt+something.
这篇关于如何禁用Alt键的正常行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!