BExplorer.Shell.ShellContextMenu.HandleMenuMessage C# (CSharp) Method

HandleMenuMessage() public method

Handles context menu messages when the ShellContextMenu is displayed on a Form's main menu bar.

To display a shell context menu in a Form's main menu, call the Populate method to populate the menu with the shell item's menu items. In addition, you must intercept a number of special messages that will be sent to the menu's parent form. To do this, you must override Form.WndProc like so:

protected override void WndProc(ref Message m) { if ((m_ContextMenu == null) || (!m_ContextMenu.HandleMenuMessage(ref m))) { base.WndProc(ref m); } }

Where m_ContextMenu is the ShellContextMenu being shown.

public HandleMenuMessage ( Message &m ) : bool
m System.Windows.Forms.Message /// The message to handle. ///
return bool
    public bool HandleMenuMessage(ref Message m) {
      //For send to menu in the ListView context menu
      if (m.Msg == (int)WM.WM_INITMENUPOPUP | m.Msg == (int)WM.WM_MEASUREITEM | m.Msg == (int)WM.WM_DRAWITEM) {
        if (m.Msg == (int)WM.WM_INITMENUPOPUP && m.WParam == _NewMenuPtr) {
          _ShellView.IsRenameNeeded = true;
        }
        if (m_ComInterface2 != null) {
          return 0 == (int)m_ComInterface2.HandleMenuMsg(m.Msg, m.WParam, m.LParam);
        }
      } else if (m.Msg == (int)WM.WM_MENUCHAR) {
        if (m_ComInterface3 != null) {
          var ptr = IntPtr.Zero;
          return 0 == (int)m_ComInterface3.HandleMenuMsg2(m.Msg, m.WParam, m.LParam, out ptr);
        }
      }

      return false;
    }