我读到的是菜单必须将其 MenuInfo.dwStyle 标志设置为 MNS_NOTIFYBYPOS,我所做的是:
MENUINFO MenuInfo;
memset(&MenuInfo,0, sizeof(MenuInfo));
MenuInfo.cbSize = sizeof(MenuInfo);
HMENU hPopupMenu = CreatePopupMenu();
GetMenuInfo(hPopupMenu, &MenuInfo);
MenuInfo.dwStyle |= MNS_NOTIFYBYPOS;
SetMenuInfo(hPopupMenu, &MenuInfo);
接下来继续添加项目:
InsertMenu(hPopupMenu, pos, MF_BYPOSITION, id , "do command");
接下来跟踪它:
TrackPopupMenu(hPopupMenu, TPM_CENTERALIGN | TPM_RETURNCMD, cursorPos.x, cursorPos.y, 0, hwnd, NULL);
但它没有效果,它编译没有错误,但点击事件直到发送为WM_COMMAND