Click here to Skip to main content
Click here to Skip to main content

Hiding the Taskbar and Startmenu (start orb) in Windows Vista and Windows 7

By , 25 Nov 2011
 

Introduction

I recently needed to hide the Windows taskbar and startmenu. All the code that I found on the net for this purpose did not work on Windows Vista, so I decided to write some by myself. The solution I have found works well on Windows XP, Windows Vista and Windows 7, both 32- and 64-bit.

Background

Hiding the taskbar is very easy, because its window handle can easily been found with a call to the FindWindow WINAPI function:

[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter,
    string className,  string windowTitle);

IntPtr taskBarWnd = FindWindow("Shell_TrayWnd", null);

Once we know the window handle, we can hide the window using the WINAPI function ShowWindow. If you do this, the taskbar is hidden, but the "Start" button still remains visible. Under Windows XP (and before) this was also easy, because the "Start" button was a child window of the taskbar and its window handle can be found with a call to FindWindowEx:

IntPtr startWnd = FindWindowEx(taskBarWnd, IntPtr.Zero, "Button", "Start");

However, this changed with Windows Vista: If you look closely, you will see that the Vista start orb is overlapping the taskbar a little bit. The start orb is not a child window of the taskbar anymore, but a window of its own. To find the handle of this window, I proceed as follows:

First, I get the id of the process that owns the taskbar window:

[DllImport("user32.dll")]
static extern uint GetWindowThreadProcessId(IntPtr hwnd, out int lpdwProcessId);

int procId;
GetWindowThreadProcessId(taskBarWnd, out procId);

Then I enumerate all threads of this process by using managed code. For each thread, I enumerate its windows by using the WINAPI function EnumThreadWindows:

Process p = Process.GetProcessById(procId);
if (p != null)
{
    // enumerate all threads of that process...
    foreach (ProcessThread t in p.Threads)
    {
        EnumThreadWindows(t.Id, MyEnumThreadWindowsProc, IntPtr.Zero);
    }
}

The EnumThreadWindows function lets Windows call my callback function MyEnumThreadWindowsProc for each window of the given thread. Within the callback function, I check whether the caption of each window is "Start" (which is true only for the start menu window):

private static bool MyEnumThreadWindowsProc(IntPtr hWnd, IntPtr lParam)
{
    StringBuilder buffer = new StringBuilder(256);
    if (GetWindowText(hWnd, buffer, buffer.Capacity) > 0)
    {
        if (buffer.ToString() == VistaStartMenuCaption)
        {
            vistaStartMenuWnd = hWnd;
            return false;
        }
    }
    return true;
}

Using the Code

I packed everything in a single static class so you don't have to worry about WINAPI. Just include the class Taskbar in your application and call the static method Hide or Show. That's all, really! Of course this works on Windows XP, Vista and Windows 7!

// hide the taskbar and startmenu
Taskbar.Hide();

History

  • 2008-04-23: Version 1.0 posted
  • 2008-07-16: Version 1.1 posted, sources updated so they should work also on non-English versions of Vista
  • 2011-11-24: Version 1.2 posted, added an alternate way to find a window handle, solution updated to VS2010

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Simon B.
Software Developer Sevitec AG
Switzerland Switzerland
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5memberKuthuparakkal23 Aug '12 - 22:05 
5
QuestionHide ONLY Start Orb from codememberManoluco17 Jul '12 - 2:35 
Hi
 
Im looking hide or remove just the Start Menu Button (in XP or Windows 7).
 
I could do it if i remove the taskbar too, but that is not that i need.
 
I read a lot of articles but i don't find anyone that explained how to hide only this (not the taskbar).
 
Can anyone help me?
 
Thanks in advance
AnswerRe: Hide ONLY Start Orb from codememberSimon B.22 Aug '12 - 11:34 
Hello
As I have written in the article above, the taskbar and the startmenu are actually different windows, which are hidden by different calls of the ShowWindow function. If you disable the first call to hide the taskbar you should get what you want.
regards,
Simon
QuestionRe: Hide ONLY Start Orb from codememberguodf13 May '13 - 20:11 
Hello
I encountered the same problem and you,Did you find a solution !
You can share your results .
QuestionHow do you determine if it is already disabled?memberKaditlehopper13 Apr '12 - 4:20 
The visibility property is write only. How would you determine, programatically, its current state?
If it is hidden I would like to show it. If it is not hidden I would like to hide it.
AnswerRe: How do you determine if it is already disabled?memberSimon B.22 Aug '12 - 11:35 
Hi
Once you know the handle of the taskbar window, it should be possible to query it's window state (don't know the WINAPI method, you have to google for it). Then you know if the window is currently hidden or not.
 
regards,
Simon
QuestionErrormemberhanonymouss8 Apr '12 - 13:09 
I get some error is vb.net on this:
 
 startWnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, DirectCast(&HC017, IntPtr), "Start")
 
This: &HC017 give me a error
 
And this one to:
 
 For Each t As ProcessThread In p.Threads
                    EnumThreadWindows(t.Id, MyEnumThreadWindowsProc, IntPtr.Zero)
                Next
 
this: MyEnumThreadWindowsProc
GeneralMy vote of 5membersapien4u28 Jan '12 - 3:52 
good
QuestionCan you explaim me bettermemberMember 856343812 Jan '12 - 17:10 
Great, I really need it. But I don´t know how setup.
How I setup the code and whitch code in my compiler to be a class?
I am using MSVC++ 2010 express. I am new in c++ and really don´t know, what file use and where setup it.
GeneralMy vote of 5membergrimertop9010 Jan '12 - 8:43 
Fantastic. I was able to convert this code to C and use it for a project of mine. Thanks very much!
GeneralMy vote of 5memberKanasz Robert29 Nov '11 - 22:52 
Good job.
QuestionNot working on windows 7 64 bitmemberdeepakgkk200315 Sep '11 - 0:21 
I have been trying to run this code on windows 7 64 bit. Simply not happening.
 
Regards,
Deepak
AnswerRe: Not working on windows 7 64 bitmemberSimon B.26 Nov '11 - 6:00 
I cannot confirm this. Can you tell me of what language your Win7 installation is?
 
regards,
Simon
AnswerRe: Not working on windows 7 64 bitmembergrimertop9017 Dec '11 - 11:36 
Works great for me on Windows 64-bit. Simon, you are my hero.
GeneralMy vote of 5membervictorbos28 Feb '11 - 12:52 
Very nice. Thanks. In case anyone else is interested, it works well on Vista (32-bit) and Win7 (32-bit).Rose | [Rose]
 
Would you by any chance know how to reposition the taskbar instead of hiding it?

modified on Tuesday, March 1, 2011 9:50 AM

GeneralMy vote of 5memberColin Maclean11 Sep '10 - 6:11 
Just what I needed for my kiosk app. Works like a charm for XP, Vista and Windows 7 (64 and 32 bit versions)
GeneralMy vote of 5memberwrapperNo15 Jul '10 - 0:00 
Worked Like a charm. Compiled it and referenced it in my VB .NET application, and simply called the functions Taskbar.Hide(), Taskbar.Show(). Worked on Windows 7 x64. Genius!!
QuestionWhat about VB.NET version?memberPeki.HR10 Dec '09 - 1:30 
What about VB.NET version?
 
Converters are having trouble with this:
 

 For Each t As ProcessThread In p.Threads
                    EnumThreadWindows(t.Id, MyEnumThreadWindowsProc, IntPtr.Zero)
                Next
 
Error 3 Argument not specified for parameter 'hWnd' of 'Private Function MyEnumThreadWindowsProc(hWnd As System.IntPtr, lParam As System.IntPtr) As Boolean'.
AnswerRe: What about VB.NET version?memberSimon B.17 Aug '10 - 11:17 
I don't know much VB syntax, so I can't help. As a workarround, try to build a class library from the C# project, then link this DLL into your VB project.
 
regards,
Simon
GeneralAlternate SolutionmemberEarl Waylon Flinn22 Jul '09 - 4:30 
I found an alternate solution that I haven't found documented anywhere on the internet.
 
If you declare FindWindowEx as follows
 
[DllImport("user32.dll")]
private static extern IntPtr FindWindowEx(IntPtr parentHwnd, IntPtr childAfterHwnd, IntPtr className, string windowText);
 
then you can access the window handle for the Start Orb like this:
 
IntPtr hwndOrb = FindWindowEx(IntPtr.Zero, IntPtr.Zero, (IntPtr)0xC017, "Start");
 
and, of course, disable it like this:
 
ShowWindow(hwndOrb, SW_HIDE);
 
The difference here 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.
GeneralRe: Alternate SolutionmemberSimon B.28 Jul '09 - 10:17 
yes, this works! thanks a lot!
Generalwindows key VS hiding startmenumemberstillomatic24 Dec '08 - 9:23 
but how to disable the Windows key that is now available on many new computer keyboards
Generalcommand linememberjnelllen2 Dec '08 - 12:14 
Are there command line switches for this so it can be run from a prompt?
GeneralAutohidememberTheShadesOfGrey6 Nov '08 - 17:49 
Any way you could make it automatically hide the taskbar and orb when it is run (without having to click hide)?
QuestionHow to make this code work for .net 1.1 versionmembervijianand6 Aug '08 - 2:27 
Your article was excellent...i've even voted for it. how can we make the same code work for .net 1.1 version?. i badly need this
AnswerRe: How to make this code work for .net 1.1 versionmemberSimon B.4 Sep '08 - 4:26 
Well, Framework 1.1 is quite old now...
But what lines cause errors when you compile under 1.1?
QuestionAnd how about Windows in other languages?memberCleyton Messias1 Jul '08 - 7:10 
Hello!
It's a really nice article!Very cool!
 
But I still have a problem.
My Windows is in Portuguese and in this piece of code:
if (buffer.ToString() == VistaStartMenuCaption)
 
I can't get the start button because it's caption is "Iniciar". Which means "Start" in portuguese.
 
How can I solve this?!
Thanks!
AnswerRe: And how about Windows in other languages?memberSimon B.3 Jul '08 - 4:45 
Thanks for your comment. Unfortunately I don't know a solution for this problem. I thought the name of the button would be independent of the OS language...
 
If anybody knows a solution please let me know!
 
So the trick described in this article works at least in English and German versions of Vista.
GeneralRe: And how about Windows in other languages?memberCleyton Messias3 Jul '08 - 6:43 
I get another solution for hiding the Task Bar and Start Button:
 
      
            // get taskbar window
            IntPtr taskBarWnd = FindWindow("Shell_TrayWnd", null);
 
            //get the start button window
            IntPtr startWnd = FindWindow("Button", null);
 
            if (taskBarWnd != IntPtr.Zero)
            {
                ShowWindow(taskBarWnd, show ? SW_SHOW : SW_HIDE);
                UpdateWindow(taskBarWnd);
            }
            if (startWnd != IntPtr.Zero)
            {
                ShowWindow(startWnd, show ? SW_SHOW : SW_HIDE);
                UpdateWindow(startWnd);
            }
 
 
I've tested here and worked! Thanks!.. Your article help me to find this way Smile | :)
GeneralRe: And how about Windows in other languages?memberSimon B.16 Jul '08 - 9:37 
Thanks a lot! This works and is a lot easier than my solution...
GeneralRe: And how about Windows in other languages?memberEarl Waylon Flinn27 Jul '09 - 4:55 
Is it the UpdateWindow call that makes this work? Seems like I remember trying FindWindow("Button", null) with just a ShowWindow.
QuestionHow can i maximee the form?membermerlin.AT2 Jun '08 - 3:59 
Hello
 
The tool works great.
But how can i get this free space for my form or other programms like office an so on?
 
Thanks a lot
Tom
AnswerRe: How can i maximee the form?memberSimon B.4 Jun '08 - 8:26 
Hello
 
If you switch a window to fullscreen it will NOT cover the space where the taskbar has been, that's right. However you can manually resize any resizable window that is not in fullscreen mode so that it covers the whole screen.
 
Normally people want to hide the taskbar from their own program which then will cover the whole screen. This can easily be done a few lines of code:
 
Form1.Left = 0;
Form1.Top = 0;
Form1.Width = Screen.Width;
Form1.Height = Screen.Height;
 
regards,
Simon
GeneralJust in timememberKavan Shaban25 Apr '08 - 15:51 
I have project right now that needs to run in kiosk mode.
 
Thanks a lot,
 
Kavan
GeneralRe: Just in timememberSteveKing27 Apr '08 - 19:28 
Never, ever hide the taskbar that way if you only want an application to run in kiosk mode!
 
The taskbar will hide itself in such situations. Please do it the correct way as described here:
 
http://blogs.msdn.com/oldnewthing/archive/2005/05/05/414910.aspx[^]
GeneralRe: Just in timememberMember 435831630 Apr '08 - 2:15 
Hi
 
Thanks for the code.
 
Could you also do a hide and unhide for just the start button so that it could be run from the command line. I am sure that I am not the only one who would like this facility.
 
cheers
AnswerRe: Hiding the start button onlymemberSimon B.1 May '08 - 9:23 
Unfortunately this is not so easy. The taskbar window still has a start button on it which will react on the click event and open the start menu. The only way I have found to disable the start menu is to hide both the taskbar window AND the additional start button window.
 
If someone knows a ways to hide the start button only, please let me know!

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 25 Nov 2011
Article Copyright 2008 by Simon B.
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid