开发者

How to get string value from mfc popupmenu when clicked without making use of resource id

开发者 https://www.devze.com 2023-03-20 14:21 出处:网络
I\'m creating a dynamic popup menu without generating resource ids. How can I keep track of the clicked action without a resource id?

I'm creating a dynamic popup menu without generating resource ids. How can I keep track of the clicked action without a resource id?

Is there any way I can get menu's string value?

CMenu m_subMenu;
m_subMen开发者_StackOverflow中文版u.CreatePopupMenu();

utf16string actionName(L"");
int nCatgryId = 1000;

for( ; itr != itrEnd ; ++itr)
{
    actionName     = itr->first;
    CString csActionName = actionName.c_str();
    AppendMenu(MF_STRING,nId++, csActionName);
}

So how do I obtain the value from the menu when an action is clicked?


#define YOURMENU_ID  WM_APP+10
...
AppendMenu(.., YOURMENU_ID,...);

And handle it in WM_COMMAND


Every menu item, when you create it, needs to have an ID. You need to reserve a list of ID's, use those to create the menu items, then use the normal menu functions to get information on them.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号