Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to Add context menu strip in notify icon of c# console application

How to Add context menu strip in notify icon of c# console application

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AhmedMasum
    wrote on last edited by
    #1

    I have written the following code. It displays the notify icon in the system tray. But when I right click on the icon in the system it's not showing any menu there. I can't understand why this is not showing the menu. Can someone help me to show this?

    ContextMenuStrip cms = new ContextMenuStrip();

            ToolStripMenuItem mI1 = new ToolStripMenuItem();
            mI1.Text = "Exit";
    
            mI1.Click += new EventHandler(Click\_Handler); //Add 
    
            cms.Items.Add(mI1);
           
            notifyIcon1.ContextMenuStrip = cms;
            notifyIcon1.Visible = true;
            
            
            notifyIcon1.Visible = true;
            notifyIcon1.BalloonTipTitle = "My service";
            notifyIcon1.Icon = new Icon("utility1.Ico");
            notifyIcon1.BalloonTipText = "Started Successfully";
            notifyIcon1.Text = "Service is running";
            notifyIcon1.ShowBalloonTip(500);
    
    L 1 Reply Last reply
    0
    • A AhmedMasum

      I have written the following code. It displays the notify icon in the system tray. But when I right click on the icon in the system it's not showing any menu there. I can't understand why this is not showing the menu. Can someone help me to show this?

      ContextMenuStrip cms = new ContextMenuStrip();

              ToolStripMenuItem mI1 = new ToolStripMenuItem();
              mI1.Text = "Exit";
      
              mI1.Click += new EventHandler(Click\_Handler); //Add 
      
              cms.Items.Add(mI1);
             
              notifyIcon1.ContextMenuStrip = cms;
              notifyIcon1.Visible = true;
              
              
              notifyIcon1.Visible = true;
              notifyIcon1.BalloonTipTitle = "My service";
              notifyIcon1.Icon = new Icon("utility1.Ico");
              notifyIcon1.BalloonTipText = "Started Successfully";
              notifyIcon1.Text = "Service is running";
              notifyIcon1.ShowBalloonTip(500);
      
      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      do you have a message pump? in a WinForm, when you show a form (with Show, ShowDialog or Application.Run) you get a message pump which deals with Windows messages and brings it all to life. A console app doesn't have a default message pump. One way to get one is by showing an invisible form (e.g. outside the desktop area). :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


      A 1 Reply Last reply
      0
      • L Luc Pattyn

        do you have a message pump? in a WinForm, when you show a form (with Show, ShowDialog or Application.Run) you get a message pump which deals with Windows messages and brings it all to life. A console app doesn't have a default message pump. One way to get one is by showing an invisible form (e.g. outside the desktop area). :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


        I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


        A Offline
        A Offline
        AhmedMasum
        wrote on last edited by
        #3

        I don't have any idea about message pump. My console application is working as a server (in client server socket programming). I wrote the code for notify icon in the main function. Can I have links or example code that will help me to display the context menu in the notify icon of my console application??

        A 1 Reply Last reply
        0
        • A AhmedMasum

          I don't have any idea about message pump. My console application is working as a server (in client server socket programming). I wrote the code for notify icon in the main function. Can I have links or example code that will help me to display the context menu in the notify icon of my console application??

          A Offline
          A Offline
          AhmedMasum
          wrote on last edited by
          #4

          I need answer please help meee...

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups