How Do I Find The Size Of The Available Display, Excluding The Taskbar?

a_unique_name 401 Reputation points

I need to know the size of the display, minus the taskbar, so I can display a window and know all the controls will be visible and accessible to the user.

I thought the following system call might offer something:

SystemParametersInfo(SPI_GETWORKAREA, ...

From the description:

The work area is the portion of the screen not obscured by the system taskbar or by application desktop toolbars.

I'm not sure what "application desktop toolbars" means. Perhaps someone can show me an example.

I think I know what the taskbar is.

I'm confused by the rectangle returned by the call.

This is a 4k display, 3840 x 2160. Because I was having trouble finding the available space I set the magnification to 100%, from the recommended 150%.

The following screenshot shows:

The SystemParametersInfo(SPI_GETWORKAREA, ... documentation.

The display settings, 100% size and 3840 x 2160.

The source code in a debugging session after a break point at the call to SystemParametersInfo().

The rectangle returned by the SystemParametersInfo() 3840 x 2160.

And, at the bottom of the screen, the taskbar which was being displayed when the call to SystemParametersInfo() was made.

The rectangle returned by SystemParametersInfo() does not exclude the taskbar.

What am I doing wrong?



A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,571 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 82,206 Reputation points

    On my OS, Windows 10 21H1, I can only reproduce this if the Taskbar is set to "auto-hide".
    You can also try with GetMonitorInfo
    like (hWnd is the main window handle in my test) :

    MONITORINFO mi = { sizeof(mi) };
    GetMonitorInfo(hMon, &mi);

    When the Taskbar is visible, I get different values in returned mi.rcMonitor and mi.rcWork

0 additional answers

Sort by: Most helpful