// Similar logic as in FE.MinMax and takes care of max/min size allowed by win32 for the hwnd. However, we // don't take Height/Width into consideration. This is because of the following reasons: // // 1) Window Height/Width info doesn't matter here since we just need to ensure that the child element is // layed out within the Max/Min restrictions of the window. Window is layed out at the size sent into MO/AO // and Height and Width of the window does not play a part MO/AO stage. // // 2) We had WOSB 1399028 FlowDocumentReader: When the maximise button is clicked on the window with FDR the // content don't reflow to fill in the entire window) and the fix for that is to simply not use H/W here. // GetWindowMinMax fixes the following bugs: // // WOSB 1330752 Window content should respect Window's Max/Min size // WOSB 1030000 Wrong window actual size returned if Autosize window content is smaller than the actual // window (seems to return content size as opposed to window size) // // This method is called by both MeasureOverride( ) and WmGetMinMaxInfo( ). // It will calculate a final Min/Max size in logic units for this HWND based on Win32 restricted value and // current Min/Max setting in this instance. // internal virtual WindowMinMax GetWindowMinMax() { WindowMinMax mm = new WindowMinMax( ); Invariant.Assert(IsCompositionTargetInvalid == false, "IsCompositionTargetInvalid is supposed to be false here"); // convert the max/min size (taken in to account the hwnd size restrictions by win32) into logical units double maxWidthDeviceUnits = _trackMaxWidthDeviceUnits; double maxHeightDeviceUnits = _trackMaxHeightDeviceUnits; if (WindowState == WindowState.Maximized) { // On some systems, the trackMax size is a few pixels smaller than // the windowMax size. Use the larger size for maximized windows. maxWidthDeviceUnits = Math.Max(_trackMaxWidthDeviceUnits, _windowMaxWidthDeviceUnits); maxHeightDeviceUnits = Math.Max(_trackMaxHeightDeviceUnits, _windowMaxHeightDeviceUnits); } Point maxSizeLogicalUnits = DeviceToLogicalUnits(new Point(maxWidthDeviceUnits, maxHeightDeviceUnits)); Point minSizeLogicalUnits = DeviceToLogicalUnits(new Point(_trackMinWidthDeviceUnits, _trackMinHeightDeviceUnits)); // // Get the final Min/Max Width // mm.minWidth = Math.Max(this.MinWidth, minSizeLogicalUnits.X); // Min's precedence is higher than Max; If Min is greater than Max, use Min. if (MinWidth > MaxWidth) { mm.maxWidth = Math.Min(MinWidth, maxSizeLogicalUnits.X); } else { if (!Double.IsPositiveInfinity(MaxWidth)) { mm.maxWidth = Math.Min(MaxWidth, maxSizeLogicalUnits.X); } else { mm.maxWidth = maxSizeLogicalUnits.X; } } // // Get the final Min/Max Height // mm.minHeight = Math.Max(this.MinHeight, minSizeLogicalUnits.Y); // Min's precedence is higher than Max; If Min is greater than Max, use Min. if (MinHeight > MaxHeight) { mm.maxHeight = Math.Min(this.MinHeight, maxSizeLogicalUnits.Y); } else { if (!Double.IsPositiveInfinity(MaxHeight)) { mm.maxHeight = Math.Min(MaxHeight, maxSizeLogicalUnits.Y); } else { mm.maxHeight = maxSizeLogicalUnits.Y; } } return mm; }
// Similar logic as in FE.MinMax and takes care of max/min size allowed by win32 for the hwnd. However, we // don't take Height/Width into consideration. This is because of the following reasons: // // 1) Window Height/Width info doesn't matter here since we just need to ensure that the child element is // layed out within the Max/Min restrictions of the window. Window is layed out at the size sent into MO/AO // and Height and Width of the window does not play a part MO/AO stage. // // 2) We had WOSB 1399028 FlowDocumentReader: When the maximise button is clicked on the window with FDR the // content don't reflow to fill in the entire window) and the fix for that is to simply not use H/W here. // GetWindowMinMax fixes the following bugs: // // WOSB 1330752 Window content should respect Window's Max/Min size // WOSB 1030000 Wrong window actual size returned if Autosize window content is smaller than the actual // window (seems to return content size as opposed to window size) // // This method is called by both MeasureOverride( ) and WmGetMinMaxInfo( ). // It will calculate a final Min/Max size in logic units for this HWND based on Win32 restricted value and // current Min/Max setting in this instance. // internal virtual WindowMinMax GetWindowMinMax() { WindowMinMax mm = new WindowMinMax( ); Invariant.Assert(IsCompositionTargetInvalid == false, "IsCompositionTargetInvalid is supposed to be false here"); // convert the max/min size (taken in to account the hwnd size restrictions by win32) into logical units Point trackMaxSizeLogicalUnits = DeviceToLogicalUnits(new Point(_trackMaxWidthDeviceUnits, _trackMaxHeightDeviceUnits)); Point trackMinSizeLogicalUnits = DeviceToLogicalUnits(new Point(_trackMinWidthDeviceUnits, _trackMinHeightDeviceUnits)); // // Get the final Min/Max Width // mm.minWidth = Math.Max(this.MinWidth, trackMinSizeLogicalUnits.X); // Min's precedence is higher than Max; If Min is greater than Max, use Min. if (MinWidth > MaxWidth) { mm.maxWidth = Math.Min(MinWidth, trackMaxSizeLogicalUnits.X); } else { if (!Double.IsPositiveInfinity(MaxWidth)) { mm.maxWidth = Math.Min(MaxWidth, trackMaxSizeLogicalUnits.X); } else { mm.maxWidth = trackMaxSizeLogicalUnits.X; } } // // Get the final Min/Max Height // mm.minHeight = Math.Max(this.MinHeight, trackMinSizeLogicalUnits.Y); // Min's precedence is higher than Max; If Min is greater than Max, use Min. if (MinHeight > MaxHeight) { mm.maxHeight = Math.Min(this.MinHeight, trackMaxSizeLogicalUnits.Y); } else { if (!Double.IsPositiveInfinity(MaxHeight)) { mm.maxHeight = Math.Min(MaxHeight, trackMaxSizeLogicalUnits.Y); } else { mm.maxHeight = trackMaxSizeLogicalUnits.Y; } } return mm; }