ive tried long and hard to get accelerator keys working, but its proved very difficult. i just cant see what im doing wrong.
i created an accelerator table with the MSVC resource editor. i added an accelerator. i defined the IDs. i added code before the message loop to load the table, and modified the message loop to translate accelerator messages. then i set up a capture in WM_COMMAND for the ID of the key. but nothing happens, no message is sent at all when i press the accelerator key. what could be wrong?
Code:IDR_ACCELERATOR1 ACCELERATORS DISCARDABLE BEGIN "Z", ACCEL_QUIT, VIRTKEY, CONTROL, ALT, NOINVERT ENDCode:if ( (table=LoadAccelerators(hInstance, (LPCTSTR)MAKELONG(MAKEINTRESOURCE(IDR_ACCELERATOR1),0)))==NULL) exit(500); // Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { if(!TranslateAccelerator(Msg.hwnd, table, &Msg)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } }Code://these are at the very top of the source file #define ACCEL_QUIT 10032 #define IDR_ACCELERATOR1 10033thats all the code involved. are there any glaring errors there, or anything im doing wrong?Code:case WM_COMMAND: { switch(LOWORD(wParam)) { case ACCEL_QUIT: MessageBox(hwnd,"Quit","!",MB_OK); PostQuitMessage(0); return 0;



LinkBack URL
About LinkBacks


