Disabling alt menu

Started by
2 comments, last by asdqwe 17 years, 8 months ago
I made a Win32 C++ game that runs in a window. But when I press Alt the game pauses because Alt opens a menu. Then it resumes when I press Alt again. How can I disable this "Alt-checking". I need Alt to be usable in my game. Thanks.
Advertisement
Don't have a menu.
Disabling the SC_KEYMENU command in a WM_SYSCOMMAND message seems to do the trick:

LRESULT CALLBACK WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {    switch (msg) {                case WM_SYSCOMMAND: {                    switch (wParam & 0xFFF0) {                            case SC_KEYMENU: {                                    return 0;                                    }break;                                default: {                                    return DefWindowProc(hWnd, msg, wParam, lParam);                                } break;                        }                } break;                        default: {                    return DefWindowProc(hWnd, msg, wParam, lParam);                    }            }        return 0;    }


Just tested it, and i think it does what you're asking for.

Make sure you return DefWindowProc() for any syscommand you don't handle, otherwise you'll disable alot more things than you intended.
---"While there is a lower class I am in it; while there is a criminal element I am of it; while there is a soul in prison, I am not free" - Eugene V. Debs---
Thanks, workingclass77.

This topic is closed to new replies.

Advertisement