Step1: New Project => Windows application project.
Step2: From the toolbaar Insert tool "NotifyIcon"
Step3: Write the code.
Step4: Make one folder in bin directory i.e. exe file image and paste the graph.ico
Below is the code for the Windows form application.
namespace TaskbarPOP
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Form form = null;
private void Form1_Load(object sender, EventArgs e)
{
try
{
string name =
System.DirectoryServices.AccountManagement.UserPrincipal.Current.DisplayName;
notifyIcon1.Icon = new System.Drawing.Icon(Path.GetFullPath(@"image\graph.ico"));
notifyIcon1.Text = "Welcome";
notifyIcon1.Visible = true;
notifyIcon1.BalloonTipTitle = "Welcome ASHWIN.";
notifyIcon1.BalloonTipText = "Have a good day.";
notifyIcon1.ShowBalloonTip(800);
/////// hiding th form //////////
form = (Form)sender;
form.ShowInTaskbar = false;
form.Opacity = 0;
//form.Close();
}
catch (Exception ex)
{
throw ex;
}
}
private void notifyIcon1_BalloonTipClosed(object sender, EventArgs e)
{
if (form != null)
form.Close();
}
}
}
To Make startup at windows: Run type=> shell:startup, Then paste the application or shortcut of application. OR below locaion
C:\Users\asharmax087101\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace StartUpNotification
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void
Form1_Load(object sender, EventArgs e)
{
try
{
this.Hide();
string[] lines;
var list = new
List<string>();
var fileStream = new System.IO.FileStream(@"C:\InUse\info.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read);
using (var
streamReader = new System.IO.StreamReader(fileStream, Encoding.UTF8))
{
string line;
while ((line = streamReader.ReadLine())
!= null)
{
list.Add(line);
}
}
lines = list.ToArray();
if (lines.Count() >= 2)
{
notifyIcon1.BalloonTipIcon = ToolTipIcon.Info;
notifyIcon1.BalloonTipText = lines[0];
notifyIcon1.BalloonTipTitle = lines[1];
notifyIcon1.ShowBalloonTip(5000);
}
}
catch (Exception
ex)
{
MessageBox.Show(@"File not
found:C:\InUse\info.txt;1.Title,2.Message--" + ex.Message);
}
}
private void
notifyIcon1_BalloonTipClicked(object sender, EventArgs e)
{
this.Close();
}
}
}
No comments:
Post a Comment