In MSDN I have found:
"Processing WM_COMMAND Messages
When an accelerator is used, the window specified in the TranslateAccelerator function receives a WM_COMMAND or WM_SYSCOMMAND message. The low-order word of the wParam parameter contains the identifier of the accelerator. The window procedure examines the identifier to determine the source of the WM_COMMAND message and process the message accordingly.
Typically, if an accelerator corresponds to a menu item in the application, the accelerator and menu item are assigned the same identifier. If you need to know whether a WM_COMMAND message was generated by an accelerator or by a menu item, you can examine the high-order word of the wParam parameter. If an accelerator generated the message, the high-order word is 1; if a menu item generated the message, the high-order word is 0."
But it is not clear to me, which message to process if I just press single key like ctrl or combination of ctrl+click or ctrl+0. This is nothing with menu. I need to install hotkey.
I have more dialog procedures in program and I have tried 3 procedures to break it in case WM_MESSAGE: but the debugger did not break there.
This is the acclerator table:
Code:
IDA_MAIN ACCELERATORS
BEGIN
"W", ID_FILE_CLOSE, VIRTKEY, CONTROL
"O", ID_FILE_OPEN, VIRTKEY, CONTROL
"S", ID_FILE_SAVE_AS, VIRTKEY, CONTROL
"C", ID_EDIT_COPY, VIRTKEY, CONTROL
"X", ID_EDIT_CUT, VIRTKEY, CONTROL
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL
VK_F2, ID_EDIT_RENAME, VIRTKEY
VK_CONTROL, IDA_CTRL, CONTROL, VIRTKEY
END
Code:
int WINAPI WinMain(HINSTANCE hWINAPI, HINSTANCE, LPTSTR cmdline, int cmdshow)
{
MSG msg;
BOOL ret;
HACCEL accelerators;
...
previousPropertySheetProc = (DLGPROC)SetWindowLong(wrapper.handles.hPropSheet, DWL_DLGPROC, (LONG)&MainPropertySheetDlgProc);
if (!accelerators)
{
MessageBox(wrapper.handles.hPropSheet,
"Keyboard Accelerators failed to load. Keyboard shortcuts will not be available.",
"Warning", MB_ICONWARNING);
}
So how to find out in which dialog process I should look for and which message?
I am using Windows XP and Visual Studio C++ 2010
Code:
while (ret = GetMessage(&msg, NULL, 0, 0))
{
if (ret < 0) //did GetMessage() fail?
{
MessageBox(wrapper.handles.hPropSheet,
"Unable to retrieve messages from queue. Click OK to terminate.",
"Fatal Error", MB_ICONERROR);
break;
}
if (TranslateAccelerator(wrapper.handles.hPropSheet, accelerators, &msg) ||
PropSheet_IsDialogMessage(wrapper.handles.hPropSheet, &msg))
continue;
// Usually active is the hSheet. If it's not, it's a modeless dialog and
// it should get a crack, too.
if ((wrapper.handles.hActivePropSheetPage = GetActiveWindow()) != wrapper.handles.hPropSheet &&
IsDialogMessage(wrapper.handles.hActivePropSheetPage, &msg))
continue;
TranslateMessage(&msg);
DispatchMessage(&msg);
}