Introduction :
How To Display message in your pc Notification Area in
WPF
Descritption :
You can set Custom icon and Custom Message in Your Pc
Notification Area
Using Code :
This code for Notify Icon
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.ContextMenu contextMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.ComponentModel.IContainer components;
private void
button1_Click(object sender, RoutedEventArgs e)
{
this.components = new System.ComponentModel.Container();
this.contextMenu1 = new System.Windows.Forms.ContextMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
// Initialize contextMenu1
this.contextMenu1.MenuItems.AddRange(
new System.Windows.Forms.MenuItem[]
{ this.menuItem1 });
// Initialize menuItem1
this.menuItem1.Index = 0;
this.menuItem1.Text = "E&xit";
this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
//// Set up how the form should be displayed.
//this.ClientSize = new
System.Drawing.Size(292, 266);
//this.Text = "Notify Icon
Example";
// Create the NotifyIcon.
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
// The Icon property sets the icon that will
appear
// in the systray for this application.
//notifyIcon1.Icon = new Icon(@"F:\DMS
AMIT\dms2\DMSProject\DMSProject\bin\Debug\No.ico");
// Set an icon using code
notifyIcon1 = new NotifyIcon();
Stream iconStream = System.Windows.Application.GetResourceStream(new Uri("pack://application:,,,/Images/No.ico")).Stream;
notifyIcon1.Icon = new
System.Drawing.Icon(iconStream);
// The ContextMenu property sets the menu
that will
// appear when the systray icon is right
clicked.
notifyIcon1.ContextMenu = this.contextMenu1;
// The Text property sets the text that will
be displayed,
// in a tooltip, when the mouse hovers over
the systray icon.
notifyIcon1.BalloonTipText = "dhaval";
notifyIcon1.BalloonTipTitle = "dhaval
error";
notifyIcon1.BalloonTipClicked += new
EventHandler(this.Balloon_DoubleClick);
notifyIcon1.Visible = true;
notifyIcon1.ShowBalloonTip(5000);
notifyIcon1.Text = "Form1
(NotifyIcon example)";
// Handle the DoubleClick event to activate
the form.
notifyIcon1.Click += new
System.EventHandler(this.notifyIcon1_DoubleClick);
}
This Code for Notify Icon Double
private void
notifyIcon1_DoubleClick(object Sender, EventArgs e)
{
//Write Down your code here when notify icon click
}
This Code for Balloon Icon Double click
private void
Balloon_DoubleClick(object Sender, EventArgs e)
{
//Write Down your code here where notify double click
}
}

0 comments:
Post a Comment