setResizeLimits usage

Hi Jules,

I’m trying to use setResizeLimits on a DocumentWindow to constraint the size of the component inside to a minimum value.
If my inside component width and height are W and H, then I would have though that

const BorderSize borders (getBorderThickness());
const BorderSize borders2 (getContentComponentBorder());
setResizeLimits(W + borders.getLeftAndRight() + borders2.getLeftAndRight(), H + borders.getTopAndBottom() + borders2.getTopAndBottom() + getTitleBarHeight(), 10000, 10000);

would be the correct code.

Unfortunately this do not work with windows with native title bar
On Windows I must add 8 to the width and 27 to the height.
On Mac I should add some too but not the same values.

Any idea what’s wrong ?
(I’m using the tip by the way)


That does look like it should work… Did you check the value that getBorderSize returns? Maybe you’re calling this before the window is on-screen, so it doesn’t yet have a way of measuring the frame thickness?

It returns only 24 as the height of borders2 on Windows XP

Other stuff are 0.(borders and getTitleBarHeight())

I’m calling it in the DocumentWindow ctor.
This is maybe the issue ?
What would be a better place to do it ?


Yeah, that sounds like the issue - it can only get the frame size when it’s on screen. Maybe try calling it after the window has been displayed.

I tried in visibilityChanged and even in paint and I’m still getting the same values as in the ctor.

It looks like something is going wrong there.


Sorry, I wasn’t thinking straight - neither of those actually gets the native frame, they just deal with the border that the ResizableWindow class should draw. You can get the native decoration size by calling getPeer()->getFrameSize().

1 Like

Works fine now.

You still need to call it outside of the ctor though otherwise you have 2 pixels off for width and height on Windows.(works fine on mac)
So far I use parentHierarchyChanged because I was not able to find a better place to put it.