Tuesday, March 4, 2014

Hide the START button and taskbar in Windows 7 or Windows XP

I had to develop a windows desktop application in Windows XP that consumed the entire desktop space. Yes, like the windows apps in the Windows 8 world. The application had to hide the taskbar and all other desktop features and open the application window in maximized state with no borders. As there was no easy way to get it done using .Net, I resorted to calling Windows API. Here is the sample code to hide and show the task bar and the START button

public static void TaskBarHide(bool pHideTaskbar)
{
      IntPtr lTaskBarHandle = FindWindow("Shell_traywnd", "");
      IntPtr lStartButton = FindWindowEx(IntPtr.Zero, IntPtr.Zero, (IntPtr)0xC017, "Start"); 

      if (pHideTaskbar == true)
      {
           ShowWindow(lStartButton, SW_HIDE);
           //SetWindowPos(lTaskBarHandle, 0, 0, 0, 0, 0, SWP_HIDEWINDOW);   // Hide Taskbar
           ShowWindow(lTaskBarHandle, SW_HIDE);
       }
       else
       {
          ShowWindow(lStartButton, SW_SHOW);
          //SetWindowPos(lTaskBarHandle, 0, 0, 0, 0, 0, SWP_SHOWWINDOW); // Show Taskbar
          ShowWindow(lTaskBarHandle, SW_SHOW); 
                 }
              }

No comments:

Post a Comment