Click here to Skip to main content
11,578,739 members (63,753 online)
Click here to Skip to main content

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

, 25 Nov 2011 CPOL 118K 5.6K 50
Rate this:
Please Sign up or sign in to vote.
How to hide the taskbar and startmenu (start orb) under Windows Vista

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)

Share

About the Author

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

You may also be interested in...

Comments and Discussions

 
QuestionIt worked Pin
Member 117487078-Jun-15 10:00
memberMember 117487078-Jun-15 10:00 
QuestionKeyboard Windows Key bring up the Start Menu... Pin
Shahram H.Farmanesh2-Mar-15 21:06
memberShahram H.Farmanesh2-Mar-15 21:06 
QuestionAwesome - but still questions... Pin
Jens Theisen29-Aug-14 3:18
memberJens Theisen29-Aug-14 3:18 
QuestionThank you so much! Pin
Member 1100365210-Aug-14 6:44
memberMember 1100365210-Aug-14 6:44 
QuestionWindows with Title "Start" Pin
Rul Aman25-Oct-13 11:01
memberRul Aman25-Oct-13 11:01 
QuestionHide the Taskbar but no the Startmenu Button. Pin
Rutkaf20-Oct-13 15:40
memberRutkaf20-Oct-13 15:40 
GeneralMy vote of 5 Pin
Kuthuparakkal23-Aug-12 22:05
memberKuthuparakkal23-Aug-12 22:05 
QuestionHide ONLY Start Orb from code Pin
Manoluco17-Jul-12 2:35
memberManoluco17-Jul-12 2:35 
AnswerRe: Hide ONLY Start Orb from code Pin
Simon B.22-Aug-12 11:34
memberSimon B.22-Aug-12 11:34 
QuestionRe: Hide ONLY Start Orb from code Pin
guodf13-May-13 20:11
memberguodf13-May-13 20:11 
QuestionHow do you determine if it is already disabled? Pin
Kaditlehopper13-Apr-12 4:20
memberKaditlehopper13-Apr-12 4:20 
AnswerRe: How do you determine if it is already disabled? Pin
Simon B.22-Aug-12 11:35
memberSimon B.22-Aug-12 11:35 
QuestionError Pin
hanonymouss8-Apr-12 13:09
memberhanonymouss8-Apr-12 13:09 
GeneralMy vote of 5 Pin
sapien4u28-Jan-12 3:52
membersapien4u28-Jan-12 3:52 
QuestionCan you explaim me better Pin
Member 856343812-Jan-12 17:10
memberMember 856343812-Jan-12 17:10 
GeneralMy vote of 5 Pin
grimertop9010-Jan-12 8:43
membergrimertop9010-Jan-12 8:43 
GeneralMy vote of 5 Pin
Kanasz Robert29-Nov-11 22:52
memberKanasz Robert29-Nov-11 22:52 
QuestionNot working on windows 7 64 bit Pin
deepakgkk200315-Sep-11 0:21
memberdeepakgkk200315-Sep-11 0:21 
AnswerRe: Not working on windows 7 64 bit Pin
Simon B.26-Nov-11 6:00
memberSimon B.26-Nov-11 6:00 
AnswerRe: Not working on windows 7 64 bit Pin
grimertop9017-Dec-11 11:36
membergrimertop9017-Dec-11 11:36 
GeneralMy vote of 5 Pin
victorbos28-Feb-11 12:52
membervictorbos28-Feb-11 12:52 
GeneralMy vote of 5 Pin
Colin Maclean11-Sep-10 6:11
memberColin Maclean11-Sep-10 6:11 
GeneralMy vote of 5 Pin
wrapperNo15-Jul-10 0:00
memberwrapperNo15-Jul-10 0:00 
QuestionWhat about VB.NET version? Pin
Peki.HR10-Dec-09 1:30
memberPeki.HR10-Dec-09 1:30 
AnswerRe: What about VB.NET version? Pin
Simon B.17-Aug-10 11:17
memberSimon B.17-Aug-10 11:17 
GeneralAlternate Solution Pin
Earl Waylon Flinn22-Jul-09 4:30
memberEarl Waylon Flinn22-Jul-09 4:30 
GeneralRe: Alternate Solution Pin
Simon B.28-Jul-09 10:17
memberSimon B.28-Jul-09 10:17 
Generalwindows key VS hiding startmenu Pin
stillomatic24-Dec-08 9:23
memberstillomatic24-Dec-08 9:23 
Generalcommand line Pin
jnelllen2-Dec-08 12:14
memberjnelllen2-Dec-08 12:14 
GeneralAutohide Pin
TheShadesOfGrey6-Nov-08 17:49
memberTheShadesOfGrey6-Nov-08 17:49 
QuestionAnd how about Windows in other languages? Pin
Cleyton Messias1-Jul-08 7:10
memberCleyton Messias1-Jul-08 7:10 
AnswerRe: And how about Windows in other languages? Pin
Simon B.3-Jul-08 4:45
memberSimon B.3-Jul-08 4:45 
GeneralRe: And how about Windows in other languages? Pin
Cleyton Messias3-Jul-08 6:43
memberCleyton Messias3-Jul-08 6:43 
GeneralRe: And how about Windows in other languages? Pin
Simon B.16-Jul-08 9:37
memberSimon B.16-Jul-08 9:37 
GeneralRe: And how about Windows in other languages? Pin
Earl Waylon Flinn27-Jul-09 4:55
memberEarl Waylon Flinn27-Jul-09 4:55 
QuestionHow can i maximee the form? Pin
merlin.AT2-Jun-08 3:59
membermerlin.AT2-Jun-08 3:59 
AnswerRe: How can i maximee the form? Pin
Simon B.4-Jun-08 8:26
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 time Pin
Kavan Shaban25-Apr-08 15:51
memberKavan Shaban25-Apr-08 15:51 
GeneralRe: Just in time Pin
SteveKing27-Apr-08 19:28
memberSteveKing27-Apr-08 19:28 
GeneralRe: Just in time Pin
Member 435831630-Apr-08 2:15
memberMember 435831630-Apr-08 2:15 
AnswerRe: Hiding the start button only Pin
Simon B.1-May-08 9:23
memberSimon B.1-May-08 9:23 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

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