我是否必须为资源编辑器中的所有弹出菜单添加虚拟菜单项?

Do I have to add a dummy menu item for all flyout menus in the Resource Editor?

这是我在资源编辑器中的菜单结构:

我不得不在我的所有弹出菜单中添加一个 ITEMS 条目。然后,在创建我的菜单以显示它时:

CMenu mnuContext, *pMnuPopup = nullptr, *pMnuSwap = nullptr, *pMnuChairman = nullptr;

mnuContext.LoadMenu(IDR_MENU_MWB_SWAP);
pMnuPopup = mnuContext.GetSubMenu(0);

if (pMnuPopup == nullptr)
    return;

pMnuSwap = pMnuPopup->GetSubMenu(0);

//# TODO Why is it I have to go through mnuContext / pMnuPopup / pMnuSwap to get to pMnuSwap?
if (pMnuSwap == nullptr)
    return;

// Extract all the flyout menus
pMnuChairman = pMnuSwap->GetSubMenu(SwapAssignment::Chairman);

// Remove the placeholders (these were added with Resource Editor)
if(pMnuChairman != nullptr)
    pMnuChairman ->DeleteMenu(0, MF_BYPOSITION);

// Now we can populate the popup menu.

为什么我必须在编辑器中添加这个虚拟菜单条目?我发现如果我不添加条目,则返回的菜单 (pMnuChairman) 是 nullptr。如果我添加虚拟条目,那么我会得到一个有效的菜单对象并可以继续。

为什么我必须这样做?

主要问题是子菜单是由其子菜单条目定义的。没有什么比空菜单更好的了。

资源编译器也不允许这样做。

这就是 Windows 资源内容的设计方式,从未真正审查过。