GetSystemMetrics vs. SystemParametersInfo

851 views Asked by At

I needed to find out the height of the screen in order to resize a dialog. I am calling GetSystemMetrics with SM_CYFULLSCREEN and I am getting a certain number (1028 in my case). Per MSDN:

To get the coordinates of the portion of the screen not obscured by the system taskbar or by application desktop toolbars, call the SystemParametersInfo function with the SPI_GETWORKAREA value.

I called SystemParametersInfo as well to see what it returns and I get a different number for the height, 1050. Running spy, the area without taskbar is indeed of height 1050. Does anyone know why the different heights? Thanks

1

There are 1 answers

0
Hans Passant On

From the MSDN docs for SM_CYFULLSCREEN:

The height of the client area for a full-screen window on the primary display monitor, in pixels.

Relevant detail bolded, the client area is the part of the window without the borders and title bar. It is therefore substantially less than the actual primary screen height. Perhaps you meant to use SM_CYSCREEN instead. SPI_GETWORKAREA returns the available space for the entire window, the outer size, the one you'd pass to CreateWindowEx().