Public partial class Form1: Form
{
[STAThread]
The static void Main ()
{
Application. EnableVisualStyles (); Application. SetCompatibleTextRenderingDefault (false); Application. The Run (new _click ());
}
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 _click ()
{
InitializeComponent ();
}
Private void axTOCControl1_OnMouseDown (object sender, ITOCControlEvents_OnMouseDownEvent e)
{
If (e.b utton!=2) return;
EsriTOCControlItem item=esriTOCControlItem. EsriTOCControlItemNone;
IBasicMap map=null;
ILayer layer=null;
The object other=null;
The 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);
The 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);
}
}
}
CodePudding user response:
M_tocControl this object is not new in structure or the load event newCodePudding user response:
The object reference not set to an instance of an object is not instantiated, later I met this question will know what do you meanCodePudding user response:
M_tocControl=new IMapControl3 ();M_tocControl. HitTest (e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
CodePudding user response: