Hide Start Orb on Vista / Win 7 in C#
c#, taskbar, windows-7, windows-vista
Solution
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.
Problem
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); ```