diff --git a/MainForm.cs b/MainForm.cs index 94f5260..4349ce5 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -26,6 +26,7 @@ namespace AppLauncher //protected const int MOD_SHIFT = 0x4; //protected const int MOD_WIN = 0x8; protected const int WM_HOTKEY = 0x312; + protected const int WM_QUERYENDSESSION = 0x0011; protected OptionsForm optionsForm = null; protected string sessionFilename = null; @@ -127,17 +128,25 @@ namespace AppLauncher protected override void WndProc(ref Message m) { - base.WndProc(ref m); - - if (m.Msg != WM_HOTKEY) return; - - switch (m.WParam.ToInt32()) + switch (m.Msg) { - case 1: - this.Visible = !this.Visible; + case WM_HOTKEY: + if (m.WParam.ToInt32() == 1) + { + this.Visible = !this.Visible; + } + + break; + case WM_QUERYENDSESSION: + requestExit = true; + this.Close(); + break; default: break; + } + + base.WndProc(ref m); } public LauncherSession CurrentSession { get; set; } = null;