Home > other >  Window aspect ratio varies depending on window size
Window aspect ratio varies depending on window size

Time:08-29

I'm trying to understand how a program is determining the new width/height when resizing it.

One would think it's merely an aspect ratio like 4:3 (which would lead to a 1.333333 ish value) however as you can see in this gif, the divition width/height throws a very different result depending on the window size.

https://gyazo.com/f3d514b9bf51f49899612090868ec140

I have seen many programs behave like this. Any idea what the algorithm is behind this?

Thanks!

CodePudding user response:

A specific window size can be forced by handling the WM_WINDOWPOSCHANGING message. You get to decide the new width and height by any algorithm you desire when the user resizes the window.

CodePudding user response:

The thing that was screwing the ratio width/height was the title, that no matter the new size, was the same height, thus ruining the ratio for every new size, on taking into account the -30 px the ratio now alwasy gives the same value.

Cheers!

  • Related