Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
[fix] 『コンテキストメニューから終了を選択したときにアイコンがタスクトレイに残り続ける問題を修正』できてなかったのを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
karukaru808 committed Jan 21, 2018
1 parent 880bae2 commit 4a6ad0f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions AltPlusPrtScr/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ class APPS : Form
private static extern int GetAsyncKeyState(int vKey);

Timer timer = new Timer();
NotifyIcon icon = new NotifyIcon();

public APPS()
{
Text = "APPS";
ShowInTaskbar = false;
setComponents();

SystemEvents.SessionEnding += new SessionEndingEventHandler(Close_Click);
Application.ApplicationExit += new EventHandler(Close_Click);

timer.Tick += new EventHandler(this.KeysWatch_Tick);
timer.Interval = 200;
Expand All @@ -42,7 +45,6 @@ private void setComponents()
// 現在のコードを実行しているAssemblyを取得
Assembly myAssembly = Assembly.GetExecutingAssembly();

NotifyIcon icon = new NotifyIcon();
icon.Icon = new Icon(myAssembly.GetManifestResourceStream("AltPlusPrtScr.app.ico"));
icon.Visible = true;
icon.Text = "APPS";
Expand Down Expand Up @@ -87,9 +89,15 @@ private void Close_Click(object sender, EventArgs e)
timer.Stop();
timer.Dispose();

SystemEvents.SessionEnding -= new SessionEndingEventHandler(Close_Click);
// NotifyIconの後処理
icon.Dispose();

// 後処理
Dispose();

SystemEvents.SessionEnding -= new SessionEndingEventHandler(Close_Click);
Application.ApplicationExit -= new EventHandler(Close_Click);

Application.Exit();
}

Expand Down
4 changes: 2 additions & 2 deletions AltPlusPrtScr/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.2")]
[assembly: AssemblyFileVersion("1.0.2")]
[assembly: AssemblyVersion("1.0.3")]
[assembly: AssemblyFileVersion("1.0.3")]

0 comments on commit 4a6ad0f

Please sign in to comment.