Notification From Icon in Statusbar - The Code Project - C# Programming
Notification From Icon in Statusbar - The Code Project - C# Programming
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please
Report this article.
Introduction
Here is an article for displaying notification from statusbar icon. And when user will double click on that icon it will open a web application. And on
right click it will display menu to Hide, Show alerts as well Exit the alerts. So we can say that here we are going to implement an application which
will work together as window based as well web based application. Here the alert will be displayed from database. And when there will not any mess
in database it will not display any notification. But when any mess will come in database it will pop up notification.
Screenshot - Notify1.gif
Screenshot - Notify2.gif
//
// Controls of window form
//
Timer :
this.tmrAlert.Enabled = true;
this.tmrAlert.Interval = 2000;
this.tmrAlert.Tick += new System.EventHandler(this.tmrAlert_Tick);
Label :
this.lblStatus.Name = "lblStatus";
NotifyIcon :
this.alertNot.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info;
this.alertNot.BalloonTipText = "Task Arrived";
this.alertNot.BalloonTipTitle = "New Task";
this.alertNot.Text = "Test all task";
this.alertNot.Visible = true;
this.alertNot.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.alertNot_MouseDoubleClick);
Label :
this.lblTotal.AutoSize = true;
this.lblTotal.Name = "lblTotal";
this.lblTotal.Text = "0";
this.lblTotal.Visible = false;
Form Property :
this.ControlBox = false;
this.Name = "AlertMess";
this.Opacity = 0.01;
this.ShowInTaskbar = false;
this.Text = "AlertMess";
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Collections;
using System.Security;
using System.Security.Permissions;
namespace AlertMessControl
{
public partial class AlertMess : Form
{
public AlertMess(string)
{
InitializeComponent();
}
lblTotal.Text = total.ToString();
int i = 1;
if(total >0)
{
foreach(DataRow dr in ds.Tables[0].Rows)
{
alertNot.ShowBalloonTip(1,dr["Mess"].ToString() , ToolTipIcon.Info);
i++;
}
con.Close();
}
BreakProcess:
// end process
if(lblStatus.Text == "H")
lblStatus.Text = "H";
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
Points of Interest
Using this code you will get a great feeling to have notification in statusbar.