title: how to add message map to dynamic menu item in MFC
body: <p>I writing a MFC which has a listview control. When the user right clicks any item , I am generating a dynamic menu item with that text that is selected in listview. Everything is displaying properly, but I do not know how to add a message map to that dynamic menu item. </p>
  
  <p>Any help?</p>
  
  <pre><code>void CMyListDlg::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult) 
      {
          // TODO: Add your control notification handler code here
  
  
          int nIndex = m_List.GetSelectionMark();
          CString pString = m_List.GetItemText(nIndex,1);
          CMenu menu, * pSubMenu;
          int pos=0;
          menu.LoadMenu(IDR_MENU1);
          pSubMenu = menu.GetSubMenu (0);
          pSubMenu-&gt;DeleteMenu(0,MF_BYPOSITION);
          pSubMenu-&gt;InsertMenu(pos,MF_BYPOSITION,NULL,pString);
              CPoint oPoint;
          GetCursorPos (&amp; oPoint);
          pSubMenu-&gt; TrackPopupMenu (TPM_LEFTALIGN, oPoint.x, oPoint.y, this);
  
  
  
  
  
  
          *pResult = 0;
      }
  </code></pre>