Tuesday, February 8, 2011

Show a ContextMenuStrip without it showing in the taskbar

I have found that when I execute the show() method for a contextmenustrip (a right click menu), if the position is outside that of the form it belongs to, it shows up on the taskbar also.

I am trying to create a right click menu for when clicking on the notifyicon, but as the menu hovers above the system tray and not inside the form (as the form can be minimised when right clicking) it shows up on the task bar for some odd reason

Here is my code currently:

private: System::Void notifyIcon1_MouseClick(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {

if(e->Button == System::Windows::Forms::MouseButtons::Right) {

     this->sysTrayMenu->Show(Cursor->Position);

    }
}

What other options do I need to set so it doesn't show up a blank process on the task bar.

  • Try assigning your menu to the ContextMenuStrip property of NotifyIcon rather than showing it in the mouse click handler.

    Cetra : Ah! You're a genius! I had no idea that they had a property for this! I was doing things the 'hard' way again :)
    acidzombie24 : You solved my problem as well
    From Groky
  • The problem I have is that my menu is available from both a double middle-click and the notification icon.

    When right clicking the notification icon, there is no taskbar button, but when I manually Show(Cursor.Position) then it shows a taskbar button.

0 comments:

Post a Comment