I have a monitor with a resolution of 1920x1200

SystemParameters.VirtualScreenWidth=1920 SystemParameters.WorkArea.Width=1920 

subscribe to resize window

 win.SizeChanged += SizeChanged; 

and in SizeChanged we get that e.NewSize.Width = 1936

Where does this number come from?

PS: I suspect that this is the width of the border 8 * 2 + 1920 (visible part), which is simply "off screen", but it sounds like nonsense.

  • Maximized probably? - andreycha

1 answer 1

I suspect that this is the width of the border 8 * 2 + 1920 (visible part), which is simply "off screen", but it sounds like nonsense.

And there is.

Border width in an unexpanded window is included in its size. For example, if you set the following window parameters in XAML:

 Left="0" Top="0" Width="1920" 

then on Windows 7 you will see a window with borders, and on Windows 10 - the gaps between the window and the edge of the screen (because the curbs in the top ten were made transparent).

When the window is maximized, only the “client” part of the window is displayed on the screen, and the borders at the same time go beyond the boundaries of the screen. From here and the "strange" size of a window.

  • But how can I find out the width of the border for the correct calculations? because the window may have a different style. - vitidev
  • @vitidev on Win7 I was able to get a value of 8 like this: SystemParameters.ResizeFrameVerticalBorderWidth + SystemParameters.FixedFrameVerticalBorderWidth + SystemParameters.BorderWidth . But I suspect that the values ​​returned by these properties may vary depending on the system, Aero turned on / off, etc. Here they offer a kind of universal way, try it. - andreycha