Hiding/Showing the Windows TaskBar
Posted
by Ashutosh R. Bhatikar
on February 1st, 2001
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 KbDownload demo project (including release build) - 28 Kb

Comments
There are no comments yet. Be the first to comment!