C# Context menu for system tray icon events not firing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ewokspy
    New Member
    • Sep 2007
    • 30

    C# Context menu for system tray icon events not firing

    I have a system tray icon with a context menu set to appear on right-click. On a right click the menu appears fine and I can select an option. The problem is that the event doesn't fire immediately. If I then go to right click again on the icon, the event fires at that time(instead of the context menu apprearing again).

    Now I have options on my menu, and both have this problem. The first option actually just calls the icon's double-click event as it's event handler. Well if I double-click the icon, the event fires immediately.

    has anyone had an issue like this before?
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    You really shouldn't call events from withen events.
    Make a function that gets called by either of the eventhandlers

    Comment

    • ewokspy
      New Member
      • Sep 2007
      • 30

      #3
      Originally posted by Plater
      You really shouldn't call events from withen events.
      Make a function that gets called by either of the eventhandlers
      Thank you for the advice, but that doesn't help regarding the problem I had.

      Plus I am not calling events within events, as I set the event handler for the context menu as the event handler for the double-click. The click event for the context menu isn't even in the code.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        So you made a systray icon and assigned it a context-menu.
        If you assign anything to the mouseclick event of your systray icon, you should make sure it "ignores" the right-click so that your context-menu will show up.

        I'm not sure what trouble you're actually having as I've always been able to do this just fine?

        Comment

        • ewokspy
          New Member
          • Sep 2007
          • 30

          #5
          Originally posted by Plater
          So you made a systray icon and assigned it a context-menu.
          If you assign anything to the mouseclick event of your systray icon, you should make sure it "ignores" the right-click so that your context-menu will show up.

          I'm not sure what trouble you're actually having as I've always been able to do this just fine?
          that's just the thing. I can't imagine what it is that could interfere with the event firing. Now this is a multi-threaded program, but I don't think that is the interference since the double-click event of the sys icon fires just fine. It's the click function of the sys icon's context menu that seems to lag behind. In order to get it to fire I have to right click (the menu pops up), select the option on the menu I want, and then right-click a second time, at which point the context menu doesn't appear again, but the original option I chose fires it's event.

          Comment

          Working...