From 40e5f65e57923bccf2e795ce1d781f15c8ecdc71 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 21 Nov 2020 00:14:03 +0000 Subject: [PATCH] Added: system shut down support --- MainForm.cs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) 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;