I would like to create a context menu,Its look something like this
HTML Code:
Delete ->Rung    ->Start 
                  ->End 
        ->Element 
Exit
my code is
Code:
case WM_RBUTTONDOWN :				//Right click option
{
	MENUITEMINFO mi1,mi2={0};
	HMENU hPopupMenu = CreatePopupMenu();
	HMENU hSubMenu1 = CreatePopupMenu();
	HMENU hSubMenu2 = CreatePopupMenu();
	
	InsertMenu(hPopupMenu,0,MF_BYPOSITION|MF_STRING,ID_EDIT_EXTEND,_T("Exit"));
	
	mi1.cbSize=sizeof(MENUITEMINFO);
	mi1.fMask=MIIM_SUBMENU|MIIM_STRING|MIIM_ID;
	mi1.wID=ID_EDIT_DELETE;
	mi1.hSubMenu=hSubMenu1;
	mi1.dwTypeData=_T("Delete");
	InsertMenu(hSubMenu1,0,MF_BYPOSITION|MF_STRING,ID_DELETE_ELEMENT,_T("Element"));
	InsertMenu(hSubMenu1,0,MF_BYPOSITION|MF_STRING,ID_DELETE_RUNG,_T("Rung"));
	
	mi2.cbSize=sizeof(MENUITEMINFO);
	mi2.fMask=MIIM_SUBMENU|MIIM_STRING|MIIM_ID;
	mi2.wID=ID_DELETE_RUNG;
	mi2.hSubMenu=hSubMenu2;
	mi2.dwTypeData=_T("Rung");
	InsertMenu(hSubMenu2,0,MF_BYPOSITION|MF_STRING,ID_DELETE_START,_T("Start"));
	InsertMenu(hSubMenu2,0,MF_BYPOSITION|MF_STRING,ID_DELETE_END,_T("End"));
	
	
	InsertMenuItem(hSubMenu1,0,false,&mi2);
	InsertMenuItem(hPopupMenu,0,false,&mi1);

	SetForegroundWindow(hWnd);
	GetCursorPos(&ptClient);
	TrackPopupMenuEx(hPopupMenu,0,ptClient.x,ptClient.y,hWnd,NULL);

	
}
But i am getting Output Like this
HTML Code:
Delete ->Rung              
          ->Element 
          ->Rung ->Start 
                 ->End 
Exit
What modification i have to do for the desired output