SetHook() public méthode

Instantiate the underlying ToolbarMenu and set the hook object to be passed into the OnCreate event of each command item.
public SetHook ( object hook ) : void
hook object
Résultat void
        private void frmMain_Load(object sender, System.EventArgs e)
        {
            //get the MapControl
            m_mapControl = (IMapControl3)axMapControl1.Object;

            //disable the Save menu (since there is no document yet)
            menuSaveDoc.Enabled = false;

            m_contextMenu = new ContextMenuClass();
            m_contextMenu.SetHook(axMapControl1.Object);

            //add the load layer file command to the map
            axToolbarControl1.AddItem(new LoadLayerFileCmd(), -1, 2, false, -1, esriCommandStyles.esriCommandStyleIconOnly);

            m_contextMenu.ContextMenu.AddItem(new SaveLayerFileCmd(), -1, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
            m_contextMenu.ContextMenu.AddItem(new RemoveLayerCmd(), -1, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
        }
    private void frmMain_Load(object sender, System.EventArgs e)
    {
      //get the MapControl
      m_mapControl = (IMapControl3)axMapControl1.Object;

      //disable the Save menu (since there is no document yet)
      menuSaveDoc.Enabled = false;

      m_contextMenu = new ContextMenuClass();
      m_contextMenu.SetHook(axMapControl1.Object);

      //add the load layer file command to the map
      axToolbarControl1.AddItem(new LoadLayerFileCmd(), -1, 2, false, -1, esriCommandStyles.esriCommandStyleIconOnly);

      m_contextMenu.ContextMenu.AddItem(new SaveLayerFileCmd(), -1, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
      m_contextMenu.ContextMenu.AddItem(new RemoveLayerCmd(), -1, -1, false, esriCommandStyles.esriCommandStyleIconAndText);
    }