Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6967707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:21:23+00:00 2026-05-27T16:21:23+00:00

I am working on a plugin (using System.ComponentModel.Composition ) for an application to place

  • 0

I am working on a plugin (using System.ComponentModel.Composition) for an application to place an icon in the notification area of the Windows UI.

trayMenu.MenuItems.Clear();

// Create context menu items
foreach( IJob job in jobs ) {
  MenuItem menuItem = new MenuItem( job.Name ) {Tag = job};
  menuItem.Click += MenuItemClick;
  trayMenu.MenuItems.Add( menuItem );
}

private void MenuItemClick( object sender, EventArgs e ) {
  // ...
}

Now when I click on an item in the context menu of that icon, the Click handler is not being invoked.
Interestingly though, when I right-click the icon again (after having clicked a menu item) the Click handler for the previously clicked MenuItem is invoked. Left-clicking or hovering over the icon does not trigger this step.

What is going on?

Update: I have a strong feeling my problem is related to this question. But I’m still trying to figure out how I could apply that to my plugin/application.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:21:24+00:00Added an answer on May 27, 2026 at 4:21 pm

    To my understanding the problem is that no window messages are being processed for the NotifyIcon (or at least not as many messages as I liked/needed).

    I solved the issue by inheriting from Form and running another message pump for my plugin.

    using System;
    using ...
    
    namespace JobTracker.Tray {
      [Export( typeof( IJobTrackerPlugin ) )]
      public class TrayPlugin : Form, IJobTrackerPlugin {
    
        #region Plugin Interface
        [Import( typeof( IJobTracker ) )]
    #pragma warning disable 649
          private IJobTracker _host;
    #pragma warning restore 649
        private IJobTracker Host {
          get { return _host; }
        }
    
        public void Initialize() {
          trayMenu = new ContextMenu();
          trayMenu.MenuItems.Add( "Exit", OnExit );
    
          trayIcon = new NotifyIcon();
          trayIcon.Icon = new Icon( SystemIcons.Application, 32, 32 );
    
          trayIcon.ContextMenu = trayMenu;
    
          // Show the proxy form to pump messages
          Load += TrayPluginLoad;
          Thread t = new Thread(
            () => {
              ShowInTaskbar    = false;
              FormBorderStyle  = FormBorderStyle.None;
              trayIcon.Visible = true;
              ShowDialog();
            } );
          t.Start();
        }
    
        private void TrayPluginLoad( object sender, EventArgs e ) {
          // Hide the form
          Size = new Size( 0, 0 );
        }
        #endregion
    
        private NotifyIcon trayIcon;    
        private ContextMenu trayMenu;
    
        private void OnExit( object sender, EventArgs e ) {
          Application.Exit();
        }
    
        #region Implementation of IDisposable
    
        // ...
    
        private void DisposeObject( bool disposing ) {
          if( _disposed ) {
            return;
          }
          if( disposing ) {
            // Dispose managed resources.
            if( InvokeRequired ) {
              EndInvoke( BeginInvoke( new MethodInvoker( Close ) ) );
            } else {
              Close();
            }
            trayIcon.Dispose();
            trayMenu.Dispose();
          }
          // Dispose unmanaged resources.
          _disposed = true;
        }
        #endregion
      }
    }
    

    Seems to work great.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a plugin system on an ASP.NET MVC application I am working
I have IMessageSender interface. using System.ComponentModel.Composition; public interface IMessageSender { void Send(string message); }
I'm using Subversive plugin in Ganymede, but after today's update it stopped working -
i m using jQuery tablsorter plugin, it's working perfect,but now problem is ... i
I am using the ajaxform() plugin, which so far is working well. However, my
I'm using the wicked Gallerriffic plugin on a gallery page, and got it working
I've implemented a slideshow using the Cycle plugin, which is working in all browsers
I'm working on a web application and using the jQuery plug-in Colorbox to pop
I am building a client server application using Java Sockets (in Windows XP). For
I'm using Intridea's Acts as Readable Rails plugin for a messaging system I'm currently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.