Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am added sub items to menu. I am trying to retrieve the selected item but not succeeded.

Please help.

Code:
C++
CMenu  menu.LoadMenu(IDR_MENU2);

CMenu *subMenu = menu.GetSubMenu(0);
CMenu *subMenu2 = subMenu->GetSubMenu(0);
//adding item 
subMenu2->AppendMenu( MF_STRING, MENU_ITEM_ID , L"(Wi-Fi)");
ON_UPDATE_COMMAND_UI(MENU_ITEM_ID, &CAudioVideoSampleDlg::OnMenuSelect)

Thanks,
Bilaal
Posted
Updated 25-Sep-13 20:34pm
v3

1 solution

Using the below code fixed my problem.thank you for the support
ON_COMMAND_RANGE(START_ID, END_ID, &OnDoSomething)
void OnDoSomething(UINT nID)
{
     int index = nid - START_ID ;
     CString str;
     subMenu2->GetMenuString(index, str, MF_BYPOSITION) ;
}

str will give the selected Item from the sub menu.

Thanks,

Bilaal
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900