I'm having problems working with Accelerators. I am using C ++.
After my window is configured and displayed.
MENUITEMINFOW mAbout; mAbout.cbSize = sizeof(MENUITEMINFO); mAbout.fMask = MIIM_TYPE | MIIM_ID; mAbout.wID = (UINT) ID_ABOUT; mAbout.fType = MFT_STRING; mAbout.dwTypeData = (LPWSTR)L"&About"; InsertMenuItemW(HelpMenu, 0, TRUE, &mAbout);
My menu works fine, and calls my field "O", there are no problems.
Now, before the message loop, I load the accelerators:
// Load accelerators. HACCEL hAccelerators = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDR_ACCELERATOR));
Then my main message loop:
while(GetMessageW(&msg, NULL, 0, 0) > 0) { if (! TranslateAcceleratorW(msg.hwnd, hAccelerators, &msg)) { TranslateMessage(&msg); DispatchMessageW(&msg); } }
My WndProc Message handle (works from the menu again)
case WM_COMMAND: { if (HIWORD(wParam) == 0) { if (LOWORD(wParam) == 101) { testDialog(hInstance ,hWnd,(LPSTR)"Testing"); } if (LOWORD(wParam) == ID_ABOUT) { DialogBox(hInstance, MAKEINTRESOURCE(IDD_ABOUTDIALOG), hWnd, &AboutDialogProc); return 0; } } break; }
My resource.rc file:
and my resource.h file:
#define IDR_ACCELERATOR 122 #define ID_ABOUT 401
And ... well, Alt-a doesn't call the window. I went all over the Microsoft website, and was very careful, but I canβt find anything vivid that I do different.
I am on Windows 7 (64 bit) using MinGW and compiling in a Unicode application.
Everything else works, but is that what I am missing ???