VC method to get the height of the taskbar

  • 2020-04-02 02:25:19
  • OfStack

This paper briefly introduces the VC to achieve the height of the task bar two methods, the specific code as follows, the reader can choose according to their own needs or to improve the modification.
Method one:


TRect rt;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rt, 0);
//The taskbar is at the height below
int y = ::GetSystemMetrics(SM_CYSCREEN)-rt.Height();
//The above
y = rt.top;
//On the left
y = rt.left;
//right
y = ::GetSystemMetrics(SM_CXSCREEN)-rt.Width();

Method 2:


HWND hwnd = ::FindWindow("Shell_TrayWnd","");
RECT rect;
::GetWindowRect(hwnd, &rect);

int nHeight = rect.bottom - rect.top;

Related articles: