How to Add context menu strip in notify icon of c# console application
-
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);
-
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);
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
-
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
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??
-
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??
I need answer please help meee...