如何给文件添加菜单


回调函数示例代码如下:

ULONG hAdvancedMenu;
AADMSMENUITEM aaMenuItem;

aaMenuItem.ulMask = AADMSMIF_FLAGS | AADMSMIF_CMDTYPE;
aaMenuItem.uiFlags = AAMIF_SEPARATOR;
aaMenuItem.uiCmdType = AAMENU_DOCUMENT;
aaApi_AddCustomMenuItem(0, AADMSMI_LAST, &aaMenuItem);

aaMenuItem.ulMask = AADMSMIF_FLAGS | AADMSMIF_NAME | AADMSMIF_CMDTYPE;
aaMenuItem.uiFlags = AAMIF_POPUP;
aaMenuItem.uiCmdType = AAMENU_DOCUMENT;
aaMenuItem.lptstrName = L"文件命令";;
hAdvancedMenu = aaApi_AddCustomMenuItem(0, AADMSMI_LAST, &aaMenuItem);

if (!hAdvancedMenu)
{
return FALSE;
}

m_uiSetFinalCmdId = aaApi_ReserveCommandIdByType(AAMENU_DOCUMENT);

aaMenuItem.ulMask = AADMSMIF_FLAGS | AADMSMIF_NAME | AADMSMIF_CMDTYPE | AADMSMIF_PROMPT |
AADMSMIF_CMDID | AADMSMIF_REQUIRED | AADMSMIF_CALLBACK |
AADMSMIF_REQUIREDS;
aaMenuItem.uiFlags = AAMIF_COMMAND;
aaMenuItem.uiCmdType = AAMENU_DOCUMENT;
aaMenuItem.lptstrPrompt = L"文件命令1";
aaMenuItem.lptstrName = L"文件命令1";
aaMenuItem.uiCommandId = m_uiSetFinalCmdId;
aaMenuItem.ulRequiredMask = AAMF_SEL_NONFINAL;
aaMenuItem.ulRequiredSMask = AAMSF_ANY_DOCUMENT;
aaMenuItem.fpExecute = lpCallback;
aaMenuItem.ushParamType = AACMDPT_DOCUMENT;

if (!aaApi_AddCustomMenuItem(hAdvancedMenu, AADMSMI_LAST, &aaMenuItem))
{
return FALSE;
}

m_uiRemoveFinalCmdId = aaApi_ReserveCommandIdByType(AAMENU_DOCUMENT);
aaMenuItem.lptstrPrompt = L"文件命令2";
aaMenuItem.lptstrName = L"文件命令2";
aaMenuItem.uiCommandId = m_uiRemoveFinalCmdId;
//aaMenuItem.ulRequiredMask = AAMF_SEL_FINAL; //设置自动变灰gray
//AAMF_SEL_ITEM_IN AAMF_SEL_ITEM_OUT AAMF_SEL_LIST_MASTER

if (!aaApi_AddCustomMenuItem(hAdvancedMenu, AADMSMI_LAST, &aaMenuItem))
{
return FALSE;
}

return TRUE;