C++ – Show a ContextMenuStrip without it showing in the taskbar

cnetwinforms

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.

Best Answer

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