Reputation: 19207
Sample menu:
IDR_MENU_PUBLISHERS_DATABASE MENU
BEGIN
POPUP "Database"
BEGIN
MENUITEM "Print\tCTRL + P", ID_DATABASE_PRINT
END
END
Handler:
void CPublishersDatabaseDlg::OnDatabasePrint()
{
CFieldServiceGroupReportDlg dlgReport(this);
dlgReport.DoModal();
}
Clicking the menu item handler works fine. But using CTRL + P does nothing. I tried creating am accelator table and using that approach by loading the table. No joy.
In the end I had to use PreTranslateMessage
like this:
BOOL CPublishersDatabaseDlg::PreTranslateMessage(MSG* pMsg)
{
BOOL bNoDispatch = FALSE, bDealtWith = FALSE;
if (IsCTRLpressed() &&
pMsg->message == WM_KEYDOWN && pMsg->wParam == _TINT{ _T('P') })
{
OnDatabasePrint();
// Eat it.
bNoDispatch = TRUE;
bDealtWith = TRUE;
}
if (!bDealtWith)
bNoDispatch = __super::PreTranslateMessage(pMsg);
return bNoDispatch;
}
Why?
Upvotes: 0
Views: 9