mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-01-17 01:35:40 -05:00
WPF NotifyIcon
--------------
FIX Dispose only deregisters OnExit event listenter if there is actually an
application (not the case in WinForms environments).
CHG Added dispose to WinForms sample which closes the NotifyIcon.
git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@121 9f600761-6f11-4665-b6dc-0185e9171623
This commit is contained in:
@@ -15,6 +15,8 @@ namespace WindowsFormsSample
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
private TaskbarIcon notifyIcon;
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -23,11 +25,20 @@ namespace WindowsFormsSample
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
TaskbarIcon tb = new TaskbarIcon();
|
||||
tb.Icon = Resources.Led;
|
||||
tb.Visibility = Visibility.Visible;
|
||||
notifyIcon = new TaskbarIcon();
|
||||
notifyIcon.Icon = Resources.Led;
|
||||
notifyIcon.ToolTipText = "Left-click to open popup";
|
||||
notifyIcon.Visibility = Visibility.Visible;
|
||||
|
||||
tb.TrayPopup = new FancyPopup();
|
||||
notifyIcon.TrayPopup = new FancyPopup();
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
base.OnClosed(e);
|
||||
|
||||
//close the notify icon
|
||||
notifyIcon.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user