Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is a maximized Delphi form 8 pixels wider and higher than the GetSystemMetrics values?

If I maximize a Delphi form the width and height values are 8 pixles greater that the corresponding GetSystemMetrics SM_CXSCREEN and SM_CYSCREEN?

For Example:

When I right click on my screen and get properties I have a 1680 X 1050 screen resolution. Those are the same values returned from GetSystemMetrics(SM_CXSCREEN) and GetSystemMetrics(SM_CYSCREEN).

When I maximize the form in my Delphi application I get a width of 1688 and a height of 1058. There is an 8 pixel difference. What causes this difference?

like image 632
Michael Riley - AKA Gunny Avatar asked Feb 02 '13 23:02

Michael Riley - AKA Gunny


1 Answers

When maximized windows were originally implemented, the designers wanted to remove the resizing borders. Rather than removing them, they instead decided to draw those borders beyond the edges of the screen, where they would not be seen. Hence the rather surprising window rectangle of a maximized window.

This implementation decision became a problem with the advent of multi-monitor systems. By that time there were applications that relied on this behaviour and so the Windows team decided to retain the behaviour for the sake of compatibility. This meant that maximized windows leaked onto neighbouring screens. In time the window manager acquired capabilities that meant it could suppress that leakage.

Raymond Chen, as usual, has an article that covers the details: Why does a maximized window have the wrong window rectangle?

like image 112
David Heffernan Avatar answered Nov 09 '22 02:11

David Heffernan