Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
579 views
in Technique[技术] by (71.8m points)

windows 7 - Hide Start Orb on Vista / Win 7 in C#

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);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...