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