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.
This commit is contained in:
Terry MacDonald 2020-11-15 21:28:15 +13:00
parent a56e68d94e
commit 73284c03f8

View File

@ -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);
}
}
}
}