Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable MessageBeep on Invalid Syskeypress

Tags:

c++

winapi

Simple problem, normally a program will produce a MessageBeep if the user presses Alt+Whatever and there's no hotkey associated with it. What API functions can I call to avoid this?

Handling WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, and WM_SYSKEYUP all with return 0; on my main WndProc does not work.

like image 822
kaykun Avatar asked Sep 07 '10 19:09

kaykun


2 Answers

WM_MENUCHAR should be what your looking for. MSDN search is you friend (>message beep shortcut< or >message beep accelerator<).

http://msdn.microsoft.com/en-us/library/ms646349(VS.85).aspx

Edit: seems to be only for active menus.
Edit 2: works like a charm. note MSDN:

An application that processes this message should return one of the following values in the high-order word of the return value.

I've used MNC_CLOSE << 16.

like image 117
dyp Avatar answered Oct 20 '22 13:10

dyp


I think this is a system setting. Control Panel + Sounds + Sounds tab. Not sure which one does it, I have a lot of them turned off. Maybe "Program Error".

like image 36
Hans Passant Avatar answered Oct 20 '22 11:10

Hans Passant