SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftMask/OCX 7.0 - Masked Edit Control
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftMask/OCX 7.0 - Masked Edit Control
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftTree/NET 2.0 - Tree Control
Compute the natural content size of a form-style window by unioning the bounding rects of its direct children. Useful for computing scroll ranges in CScrollView or any host that needs to size itself to its template content.
C
SIZE SftDarkMode_GetNaturalChildSize(HWND hwnd, int padRight, int padBottom);
hwnd
The parent window whose direct children should be measured.
padRight
Right-edge padding to add to the union, in pixels. Pass 0 for no padding. The padding ensures the rightmost control is not flush against the parent's edge.
padBottom
Bottom-edge padding to add to the union, in pixels. Pass 0 for no padding.
A SIZE whose cx / cy are the width and height of the union of every direct child's bounding rect, in hwnd's client coordinates, plus the padding. Returns {0, 0} if hwnd is NULL or has no children.
Despite living in the SftDarkMode header, this is a general-purpose layout helper - it is unrelated to dark mode and has no dependency on the rest of the helper. It is included here because the same dialog hosts that need the dark-mode helpers (CFormView, dialog templates rendered as scrolling forms) typically also need a natural-size computation after a PerMonitorV2 DPI change.
Under PerMonitorV2 DPI awareness, Windows repositions the dialog-template children automatically when the host moves to a different-DPI monitor. After the repositioning, the union of the children's bounding rects is the new natural size at the new DPI, with no manual MulDiv required. Pass the result to CScrollView::SetScrollSizes (or equivalent) to update the scrollbar range.
// In OnSize / OnDpiChangedAfterParent: SIZE szContent = SftDarkMode_GetNaturalChildSize(m_hWnd, 16, 16); SetScrollSizes(MM_TEXT, szContent);
The function does not recurse - only direct children are considered. Composite controls that own internal children contribute their outer bounding rect, not their inner layout.
See Also ApplyToDialog
