0

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_subMenu.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?

sth
  • 222,467
  • 53
  • 283
  • 367
Pinky
  • 1,217
  • 4
  • 17
  • 27

2 Answers2

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

And handle it in WM_COMMAND

Ajay
  • 18,086
  • 12
  • 59
  • 105
0

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.

Roel
  • 19,338
  • 6
  • 61
  • 90