COM context menu InvokeCommand not being called

36 views Asked by At

I use the following code to set up my context menu:

HRESULT __stdcall CMyContextMenu::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) {
    if (CMF_DEFAULTONLY & uFlags)
    {
        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));
    }

    UINT idCmdCurrent = idCmdFirst;

    logging::log(conversions::to_string(idCmdCurrent));
    InsertMenu(
        hmenu,
        indexMenu,
        MF_STRING | MF_BYPOSITION,
        idCmdCurrent++,
        _T("Test Command")
    );

    logging::log(conversions::to_string(idCmdCurrent));
    logging::log(conversions::to_string(idCmdCurrent - idCmdFirst));
    return MAKE_HRESULT(SEVERITY_SUCCESS, 0, idCmdCurrent - idCmdFirst);
}

HRESULT __stdcall CMyContextMenu::InvokeCommand(CMINVOKECOMMANDINFO* pici) {
    logging::log("Test Command invoked");

    return S_OK;
}

I can see through logging, and through testing, that my command is being added to the context menus correctly.

However, when I click on the context menu item, my command is not being invoked. I went through the ID's for my command ad nauseam, but it seems to me that they are correct.

I am stumped for what my next step would be in debugging the extension. Please help?

0

There are 0 answers