protected Rectangle GetWindowRectangle(Form frm) { Rectangle snapshotBounds = Rectangle.Empty; DockState[] dockedStates = new DockState[] { DockState.DockBottom, DockState.DockLeft, DockState.DockBottom, DockState.DockTop, DockState.Document }; if (frm is DockableForm && dockedStates.Any((state) => ((frm as DockableForm).DockState == state))) { Point origin = Point.Empty; frm.Invoke(new Action(() => { origin = frm.PointToScreen(new Point(0, 0)); })); PointAdditive frameOffset = new PointAdditive(-((frm as DockableForm).Pane.Width - frm.Width) / 2, -((frm as DockableForm).Pane.Height - frm.Height)); snapshotBounds = new Rectangle(origin + frameOffset, (frm as DockableForm).Pane.Size); } else { if (frm.ParentForm is FloatingWindow) { frm = frm.ParentForm; } int frameWidth = (frm.DesktopBounds.Width - frm.ClientRectangle.Width) / 2 - SystemInformation.Border3DSize.Width + SystemInformation.BorderSize.Width; Size imageSize = frm.Size + new PointAdditive(-2 * frameWidth, -frameWidth); Point sourcePoint = frm.Location + new PointAdditive(frameWidth, 0); snapshotBounds = new Rectangle(sourcePoint, imageSize); } return(snapshotBounds * GetScalingFactor()); }