890918 - keystroke seems not to generate the desired command
-
hi i defined an accelerator Ctrl+T to generate ID_TMPDLG. i put
ON\_COMMAND(ID\_TMPDLG, &Ct2App::OnTmpDlg)
but the function is not called. i tried to see whether to message for the accelerator is generated correctly and i tested it in:
BOOL Ct2App::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == 'T')
return CWinAppEx::PreTranslateMessage(pMsg);
return CWinAppEx::PreTranslateMessage(pMsg);
}by defining a break point, i realized that the line is hit and the message is produced correctly. but i don't know why the command ID_TMPDLG is not generated or received by the application. i tried to handle the command in another places like main frame and child view, but it didn't help and the command is not still generated or received. i don't know whether the accelerator message is not converted into the command or the message is lost somewhere. what can i do? thx
-
hi i defined an accelerator Ctrl+T to generate ID_TMPDLG. i put
ON\_COMMAND(ID\_TMPDLG, &Ct2App::OnTmpDlg)
but the function is not called. i tried to see whether to message for the accelerator is generated correctly and i tested it in:
BOOL Ct2App::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == 'T')
return CWinAppEx::PreTranslateMessage(pMsg);
return CWinAppEx::PreTranslateMessage(pMsg);
}by defining a break point, i realized that the line is hit and the message is produced correctly. but i don't know why the command ID_TMPDLG is not generated or received by the application. i tried to handle the command in another places like main frame and child view, but it didn't help and the command is not still generated or received. i don't know whether the accelerator message is not converted into the command or the message is lost somewhere. what can i do? thx
-
1.) create an accelerator resource. 2.) load them: _haccel = LoadAccelerator(0,MAKEINTRESOURCE()) 3.) translate them by calling TranslateAccelerator() have a nice day.
oh thanx so u mean my defined accelerator is not loaded or is not translated? i put it in the only one pre-existing accelerator list with the id of IDR_MAINFRAME. if it's not loaded the other defined accelerators in the list must also not work, but they do. for example Ctrl+S brings up the Save As dialog, etc. how can i justify this and how can i check that whether an accelerator is loaded or translated properly and where in the program does this happen? thx
-
oh thanx so u mean my defined accelerator is not loaded or is not translated? i put it in the only one pre-existing accelerator list with the id of IDR_MAINFRAME. if it's not loaded the other defined accelerators in the list must also not work, but they do. for example Ctrl+S brings up the Save As dialog, etc. how can i justify this and how can i check that whether an accelerator is loaded or translated properly and where in the program does this happen? thx
-
"so u mean my defined accelerator is not loaded or is not translated?" yes indeed - set a breakpoint at the TranslateMessage of the base class. enshure your accelerators are loaded. it seems only the predefined accelerators will work. good luck.
i couldn't find TranslateMessage! it seems to be an API function, not belonging to any class. TranslateMessage of what class u mean?