diff --git a/mRemoteNG/Connection/Protocol/IntegratedProgram.cs b/mRemoteNG/Connection/Protocol/IntegratedProgram.cs index 26243bf47..d6c8f0c0e 100644 --- a/mRemoteNG/Connection/Protocol/IntegratedProgram.cs +++ b/mRemoteNG/Connection/Protocol/IntegratedProgram.cs @@ -139,10 +139,13 @@ namespace mRemoteNG.Connection.Protocol try { if (InterfaceControl.Size == Size.Empty) return; - NativeMethods.MoveWindow(_handle, -SystemInformation.FrameBorderSize.Width, - -(SystemInformation.CaptionHeight + SystemInformation.FrameBorderSize.Height), - InterfaceControl.Width + SystemInformation.FrameBorderSize.Width * 2, - InterfaceControl.Height + SystemInformation.CaptionHeight + + // Use ClientRectangle to account for padding (for connection frame color) + Rectangle clientRect = InterfaceControl.ClientRectangle; + NativeMethods.MoveWindow(_handle, + clientRect.X - SystemInformation.FrameBorderSize.Width, + clientRect.Y - (SystemInformation.CaptionHeight + SystemInformation.FrameBorderSize.Height), + clientRect.Width + SystemInformation.FrameBorderSize.Width * 2, + clientRect.Height + SystemInformation.CaptionHeight + SystemInformation.FrameBorderSize.Height * 2, true); } catch (Exception ex) diff --git a/mRemoteNG/Connection/Protocol/PowerShell/Connection.Protocol.PowerShell.cs b/mRemoteNG/Connection/Protocol/PowerShell/Connection.Protocol.PowerShell.cs index 368f04c0b..9e1a67cc3 100644 --- a/mRemoteNG/Connection/Protocol/PowerShell/Connection.Protocol.PowerShell.cs +++ b/mRemoteNG/Connection/Protocol/PowerShell/Connection.Protocol.PowerShell.cs @@ -229,10 +229,13 @@ namespace mRemoteNG.Connection.Protocol.PowerShell try { if (InterfaceControl.Size == Size.Empty) return; - NativeMethods.MoveWindow(_handle, -SystemInformation.FrameBorderSize.Width, - -(SystemInformation.CaptionHeight + SystemInformation.FrameBorderSize.Height), - InterfaceControl.Width + SystemInformation.FrameBorderSize.Width * 2, - InterfaceControl.Height + SystemInformation.CaptionHeight + + // Use ClientRectangle to account for padding (for connection frame color) + Rectangle clientRect = InterfaceControl.ClientRectangle; + NativeMethods.MoveWindow(_handle, + clientRect.X - SystemInformation.FrameBorderSize.Width, + clientRect.Y - (SystemInformation.CaptionHeight + SystemInformation.FrameBorderSize.Height), + clientRect.Width + SystemInformation.FrameBorderSize.Width * 2, + clientRect.Height + SystemInformation.CaptionHeight + SystemInformation.FrameBorderSize.Height * 2, true); } catch (Exception ex)