From 7f93cf0a42d88234b00eed5d7597401d33ea3011 Mon Sep 17 00:00:00 2001 From: sseifert Date: Thu, 17 Mar 2016 10:44:54 +0100 Subject: [PATCH] better handling of change in virtual screen size --- AEMManager/util/SystemUtil.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/AEMManager/util/SystemUtil.cs b/AEMManager/util/SystemUtil.cs index 396dbbc..71774df 100644 --- a/AEMManager/util/SystemUtil.cs +++ b/AEMManager/util/SystemUtil.cs @@ -66,11 +66,19 @@ public static void RestoreWindowPos(Form pfrm, int left = 0, int top = 0, int wi key.Close(); } - if (pfrm.Left > SystemInformation.VirtualScreen.Width - 50) { - pfrm.Left = left > 0 ? left : 10; + if (pfrm.FormBorderStyle == FormBorderStyle.Sizable || pfrm.FormBorderStyle == FormBorderStyle.SizableToolWindow) { + if (pfrm.Width > SystemInformation.VirtualScreen.Width) { + pfrm.Width = SystemInformation.VirtualScreen.Width - 20; + } + if (pfrm.Height > SystemInformation.VirtualScreen.Height) { + pfrm.Height = SystemInformation.VirtualScreen.Height - 20; + } + } + if (pfrm.Left + pfrm.Width > SystemInformation.VirtualScreen.Width) { + pfrm.Left = SystemInformation.VirtualScreen.Width - pfrm.Width - 10; } - if (pfrm.Top > SystemInformation.VirtualScreen.Height - 50) { - pfrm.Top = top > 0 ? top : 10; + if (pfrm.Top + pfrm.Height > SystemInformation.VirtualScreen.Height) { + pfrm.Top = SystemInformation.VirtualScreen.Height - pfrm.Height - 10; } }