Why is CTRL + P not firing for my CDialog menu item?

18 Views Asked by At

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?

0

There are 0 best solutions below