好久好久都验证码不通过,现在终于可以了.高兴!发一篇,关于ArcEngine右键开发.
两种方法,一种是.net的contextmenustrip,一种是arcengine的toccontrol.
分别如下:
//ContextMenuStrip实现右键菜单
if (e.button != 2) return;
esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone;
IBasicMap pMap = null;
ILayer pLayer = null;
object pOther = new object();
object pIndex = new object();
axTOCControl.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref pOther, ref pIndex);
if (pItem == esriTOCControlItem.esriTOCControlItemLayer)
{
Point p = new Point();
p.X = e.x;
p.Y = e.y;
contextMenuStrip.Show(axTOCControl, p);
}
//ToCControl实现右键菜单
if (e.button != 2) return;
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);
if (item == esriTOCControlItem.esriTOCControlItemLayer)
m_tocControl.SelectItem(layer, null);
m_mapControl.CustomProperty = layer;
if (item == esriTOCControlItem.esriTOCControlItemLayer) m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd);
其中第二种方法,在ArcEnine的DoNet实例代码中可以找到.