• Advertisement
Sign in to follow this  

Alt + Enter Switching

This topic is 2815 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Hi Pablo24, my snippet looked like a big hack if compared to your code! Thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement