Sign in to follow this  
LeJa

Alt + Enter Switching

Recommended Posts

Hi, what can I do to stop the ugly system beep which Windows does when the user press a combination of alt + something in a window created with the Win32 API? Nestopia dont emits this beep, I read the source code of it, but I am not sure of how it did this... Thanks! [Edited by - LeJa on May 4, 2010 7:41:28 PM]

Share this post


Link to post
Share on other sites
Hi guys, I finally made it work. The secret is to test the key combination before the calls to the TranslateMessage and DispatchMessage functions. And when you want to accept the key combination, you replace the current message with the next message from the queue by using PeekMessage. Example:


if (msg.message == WM_SYSKEYDOWN) {
if (msg.wParam == VK_RETURN && GetAsyncKeyState(VK_MENU)) {
SwitchMode()
PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE);
};
};
TranslateMessage(&msg);
DispatchMessage(&msg);



Thanks!

Share this post


Link to post
Share on other sites
You should add this to your Window Procedure:
case WM_SYSCOMMAND:
{
if((wParam & ~0xF) == SC_KEYMENU)
{
// Disable Beep on Alt+[Key]
return 0;
}
return DefWindowProc(m_hWnd, uMessage, wParam, lParam);
break;
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this