From 73284c03f81011636e192f98eeb8f2aa4174569b Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Sun, 15 Nov 2020 21:28:15 +1300 Subject: [PATCH] Fixed open application window menu The Open Application Window notification icon popup menu item wouldn't restore the window if it was minimised before running the Open Application Window command. Added some cool code from https://stackoverflow.com/questions/ 354445/restore-windowstate-from-minimized and then tweaked it to work in this situation. I could have added this a much better place in the application but I am planning on rewriting the app in WPF eventually so I don't really need to do so. --- HeliosPlus/UIForms/MainForm.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/HeliosPlus/UIForms/MainForm.cs b/HeliosPlus/UIForms/MainForm.cs index 98fda4d..61834f1 100644 --- a/HeliosPlus/UIForms/MainForm.cs +++ b/HeliosPlus/UIForms/MainForm.cs @@ -11,6 +11,7 @@ using HeliosPlus.GameLibraries; using System.Threading; using System.Reflection; using HeliosPlus.Shared; +using System.Runtime.InteropServices; namespace HeliosPlus.UIForms { @@ -187,6 +188,7 @@ namespace HeliosPlus.UIForms private void openApplicationWindowToolStripMenuItem_Click(object sender, EventArgs e) { allowVisible = true; + Restore(); Show(); BringToFront(); } @@ -218,5 +220,18 @@ namespace HeliosPlus.UIForms Program.AppProgramSettings.MinimiseOnStart = false; } } + + [DllImport("user32.dll")] + private static extern int ShowWindow(IntPtr hWnd, uint Msg); + + private const uint SW_RESTORE = 0x09; + + public void Restore() + { + if (WindowState == FormWindowState.Minimized) + { + ShowWindow(Handle, SW_RESTORE); + } + } } }