/// <summary> /// Popup the context menu at the given location /// </summary> /// <param name="X">X coordinate where to popup the menu</param> /// <param name="Y">Y coordinate where to popup the menu</param> /// <param name="hWndParent">Handle to the parent window</param> public void PopupMenu(int X, int Y, int hWndParent) { if (m_toolbarMenu != null) { m_toolbarMenu.PopupMenu(X, Y, hWndParent); } }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { if (e.button == 1) { //MessageBox.Show("左键按下"); } else if (e.button == 2) { //MessageBox.Show("右键按下"); esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; IBasicMap map = null; ILayer layer = null; object other = null; object index = null; //判断所选菜单的类型 m_TOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //确定选定的菜单类型,Map或是图层菜单 if (item == esriTOCControlItem.esriTOCControlItemMap) { m_TOCControl.SelectItem(map, null); } else { m_TOCControl.SelectItem(layer, null); } //设置CustomProperty为layer (用于自定义的Layer命令) m_mapControl.CustomProperty = layer; //弹出右键菜单 //if (item == esriTOCControlItem.esriTOCControlItemMap) // m_menuMap.PopupMenu(e.x, e.y, m_TOCControl.hWnd); if (item == esriTOCControlItem.esriTOCControlItemLayer) { m_MenuLayer.PopupMenu(e.x, e.y, m_TOCControl.hWnd); } else { MessageBox.Show("shit!"); } } }