Hiding/Showing the Windows TaskBar | CodeGuru

Hiding/Showing the Windows TaskBar

I was writing an application which had a requirement saying that the Windows taskbar needs to be hidden. While looking out for source code, I came across SystemParametersInfo() API in MSDN, which retrieves the size of the work area on the primary display monitor. The work area is the portion of the screen not obscured […]

Written By
CodeGuru Staff
CodeGuru Staff
Feb 1, 2001
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

I was writing an application which had a requirement saying that the Windows taskbar needs to be hidden. While looking out for source code, I came across SystemParametersInfo() API in MSDN, which retrieves the size of the work area on the primary display monitor. The work area is the portion of the screen not obscured by the system taskbar or by application desktop toolbars.

Now, my only requirement was to retrieve the handle to the TaskBar window. I used CWnd’s FindWindow() function to do this. FindWindow() takes two parameters, the window’s class name (a WNDCLASS structure) and the windw name (the windows title). You may retrieve these properties of the window using the SPY++’s FindWindow utility that comes with Visual Studio.

Using these two functions I came up with the following code which you can use to either show or hide the taskbar and utilize the full desktop.

void gShowHideTaskBar(BOOL bHide /*=FALSE*/)
{
 CRect rectWorkArea = CRect(0,0,0,0);
 CRect rectTaskBar = CRect(0,0,0,0);
 CWnd* pWnd = CWnd::FindWindow(“Shell_TrayWnd”, “”);
 if( bHide )
 {
  // Code to Hide the System Task Bar
  SystemParametersInfo(SPI_GETWORKAREA,
                       0,
                       LPVOID)&rectWorkArea,
                       0);
  if( pWnd )
  {
   pWnd->GetWindowRect(rectTaskBar);
   rectWorkArea.bottom += rectTaskBar.Height();
   SystemParametersInfo(SPI_SETWORKAREA,
                        0,
                        LPVOID)&rectWorkArea,
                        0);
   pWnd->ShowWindow(SW_HIDE);
  }
 }
 else
 {
  // Code to Show the System Task Bar
  SystemParametersInfo(SPI_GETWORKAREA,
                       0,
                       (LPVOID)&rectWorkArea,
                       0);
  if( pWnd )
  {
   pWnd->GetWindowRect(rectTaskBar);
   rectWorkArea.bottom -= rectTaskBar.Height();
   SystemParametersInfo(SPI_SETWORKAREA,
                        0,
                        (LPVOID)&rectWorkArea,
                        0);
   pWnd->ShowWindow(SW_SHOW);
  }
 }
}

Downloads

Download source – 2 Kb
Download demo project (including release build) – 28 Kb

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.