The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Vista32 ALT+Key Beeps in Window Mode
Thomas Omilian
Guest

Hi, I'm using SDL on Vista32 as a selfcompiled DLL (MinGW/Code::Blocks).
Yesterday I noticed that when I press the ALT-Key with an alphanumeric key,
the system plays a MessageBeep(). This was with SDL 1.2.14. When changing
the DLL to 1.2.13 there is no beep.
The function of my program executes normally, except the beep with SDL
1.2.14. I can't find any calls the a MessageBeep() in the SDL-Sources.
I disabled the functionality in my program but the Beep was already there.
It is played on keyDown and only in Windowed Mode, not in Fullscreen.
Is this a suggested behavior ?

MfG,
Thomas Omilian


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Solution: Window ALT+Key Beeps in Window Mode
ginkgobitter


Joined: 28 Jul 2011
Posts: 18
I found myself dealing with the same (non-)issue/annoyance today Wink And since I could hardly find any information on it - here's a quick summary and a workaround.
If the dinging appears depends on how the window is set up. If you have the ALT key pressed, any other key will make windows try to search for an appropriate menue item on the window - if it cannot be found you get the "you did something wrong"-ding... Responsible for all that is the window message WM_SYSCOMMAND and more precisely its SC_KEYMENU command. Since with native SDL there is no way to filter those events (WM_SYSCOMMANDs get passed along by default even if a filter is set), the only solution I found is nesting the SDL message handler in my own and filter the event that way.

Code:
#ifdef _WIN32
WNDPROC OldWndProc = NULL;

LRESULT CALLBACK
DeDinger(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam) {
   if (msg==WM_SYSCOMMAND && (wparam&0xfff0) == SC_KEYMENU)
      return 0;
   return CallWindowProc(OldWndProc, wnd, msg, wparam, lparam);
}

void
toggleDingFilter(HWND wnd) {
   if (OldWndProc) {
      SetWindowLongPtr(wnd, GWLP_WNDPROC, (LONG_PTR)OldWndProc);
      OldWndProc = NULL;
   } else {
      OldWndProc = (WNDPROC)GetWindowLongPtr(wnd, GWLP_WNDPROC);
      SetWindowLongPtr(wnd, GWLP_WNDPROC, (LONG_PTR)&DeDinger);
   }
}
#endif