AE未将对象引用设置到对象的实例
代码如下,求大佬帮忙看看:
public partial class Form1 : Form
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1());
}
private ITOCControl2 m_tocControl = null;
private IToolbarMenu m_menuMap = null;
private IToolbarMenu m_menuLayer = null;
private IMapControl3 m_mapControl = null;
//private ILayer layer;
//private esriTOCControlItem item;
public Form1()
{
InitializeComponent();
}
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
{
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.esriTOCControlItemMap)
m_tocControl.SelectItem(map, null);
else
m_tocControl.SelectItem(layer, null);
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);
}
}
}