修改菜单项 [英] Modifying menu items

查看:93
本文介绍了修改菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个想要在显示之前修改的弹出菜单.我实际上可以修改菜单项的字符串.问题是,这使它无用,因为单击修改后的菜单项时什么也没发生.

I have a popup menu I would like to modify before it is being displayed. I can actually modify the string of a menu item fine. The problem is, that this renders it useless as nothing happens when the modified menu item is clicked on.

CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);

CWnd* pWndPopupOwner = this;
while(pWndPopupOwner->GetStyle() & WS_CHILD)
    pWndPopupOwner = pWndPopupOwner->GetParent();

// modify string
pPopup->ModifyMenu(1, MF_BYPOSITION | MF_STRING, NULL, oss.str().c_str());

pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner);

推荐答案

您对ModifyMenu的调用将菜单的ID设置为零(通过第三个参数).您需要保持该ID不变.

Your call to ModifyMenu is setting the menu's ID to zero (via the third argument). You need to keep that ID the same.

如果这很尴尬,则SetMenuItemInfo API可让您在不更改ID的情况下更改字符串.

If that's awkward, the SetMenuItemInfo API lets you change the string without changing the ID.

这篇关于修改菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆