M
MikeMayUK999
Guest
The code generated for a desktop app by VS seems to be incorrect. In the message loop it makes the following call:
TranslateAccelerator(msg.hwnd, hAccelTable, &msg)
This will cause the translated message (WM_COMMAND or WM_SYSCOMMAND) to be sent to the WndProc for the window or control that had the focus when the accelerator was invoked by the user (msg.hwnd). However, command messages are handled by the WndProc of the main application window. Thus, the following amendments are required:
1. Change InitInstance() to return the HWND of the main application window
2. Pass the return value from InitInstance() (call it hWnd) to TranslateAccelerator as follows: TranslateAccelerator(hWnd, hAccelTable, &msg)
That's how I got my accelerators to work.
Continue reading...
TranslateAccelerator(msg.hwnd, hAccelTable, &msg)
This will cause the translated message (WM_COMMAND or WM_SYSCOMMAND) to be sent to the WndProc for the window or control that had the focus when the accelerator was invoked by the user (msg.hwnd). However, command messages are handled by the WndProc of the main application window. Thus, the following amendments are required:
1. Change InitInstance() to return the HWND of the main application window
2. Pass the return value from InitInstance() (call it hWnd) to TranslateAccelerator as follows: TranslateAccelerator(hWnd, hAccelTable, &msg)
That's how I got my accelerators to work.
Continue reading...