8

When hiding the Task Bar on Vista and Windows 7 the Start Button (also known as the Start Orb) doesn't get hidden. I've been looking for a solution to this and I've found one but it seems more complex than necessary. This CodeProject article describes (and contains code for) a solution where you enumerate all child windows of all threads in the process that contains the start menu.

Has anyone found a simpler solution?

Just for reference. The code for hiding the Task Bar (without hiding the Orb) is as follows. First do the necessary Win32 imports and declarations.

[DllImport("user32.dll")]
private static extern IntPtr FindWindow(string className, string windowText);

[DllImport("user32.dll")]
private static extern int ShowWindow(IntPtr hwnd, int command);


private const int SW_HIDE = 0;
private const int SW_SHOW = 1;

Then, in a method somewhere, call them with the right arguments

IntPtr hwndTaskBar = FindWindow("Shell_TrayWnd", "");
ShowWindow(this.hwndTaskBar, SW_HIDE);
Waylon Flinn
  • 19,969
  • 15
  • 70
  • 72
  • I think this is somewhat of a duplicate question. Someone already posted asking how to hide the taskbar and the solution given is to have the form.WindowState = FormWindowState.Maximized; form.FormBorderStyle = FormBorderStyle.None; This combo should hide the taskbar quite well. I have no problem doing this on Win7. Didn't try it on Vista. – Jimmy Chandra Jul 22 '09 at 14:58
  • That doesn't hide the Task Bar. It covers it up. – Waylon Flinn Jul 22 '09 at 15:01
  • See http://stackoverflow.com/questions/505167/how-do-i-make-a-winforms-app-go-full-screen – Jimmy Chandra Jul 22 '09 at 15:02
  • Ah... you want it to go away altogehter? :) – Jimmy Chandra Jul 22 '09 at 15:03
  • Yes. I don't have the luxury of covering the entire screen with a single window. – Waylon Flinn Jul 22 '09 at 15:06
  • 2
    You can create a secondary window that covers the screen, and then let your other windows do whatever they like. Don't run around hiding the taskbar manually -- what if two programs did that? Or what if your program crashes before it gets a chance to unhide it? – Raymond Chen Mar 21 '12 at 06:24
  • @RaymondChen Program crash before unhiding is definitely a problem with this approach. Perhaps you can help to get a cleaner way to accomplish this included in the OS? As I indicated in the comment directly above yours, I don't have the luxury of covering the entire screen with a single window. – Waylon Flinn Mar 21 '12 at 18:57
  • Creating a fullscreen window is the only option. Can't you just spin off a worker thread to create a dummy fullscreen window? – Raymond Chen Mar 21 '12 at 20:25

1 Answers1

12

I was able to put together a solution that didn't require all the thread enumeration. Here are the relevant parts.

If you declare FindWindowEx as follows

[DllImport("user32.dll")]
private static extern IntPtr FindWindowEx(
       IntPtr parentHwnd,
       IntPtr childAfterHwnd,
       IntPtr className,
       string windowText);

You can then access the window handle for the Start Orb like this:

IntPtr hwndOrb = FindWindowEx(IntPtr.Zero, IntPtr.Zero, (IntPtr)0xC017, null);

and disable the Start Orb like this:

ShowWindow(hwndOrb, SW_HIDE);

The key to this method is that we use the IntPtr type for the className variable instead of a string in the FindWindowEx function. This allows us to use the portion of this function that takes an ATOM type rather than a string. I was able to discern that the particular ATOM to use is at 0xC017 from this post: Hide Vista Start Orb

Hope this simplified version helps some people.

UPDATE: I created this new Code Project Page to document this process.

Waylon Flinn
  • 19,969
  • 15
  • 70
  • 72