Click here to Skip to main content
6,635,160 members and growing! (17,692 online)
Email Password   helpLost your password?
Desktop Development » Miscellaneous » General     Intermediate License: The Code Project Open License (CPOL)

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

By Simon B.

How to hide the taskbar and startmenu (start orb) under Windows Vista
C# (C# 2.0), Windows (Vista), .NET (.NET 2.0), Win32, Dev
Posted:25 Apr 2008
Updated:17 Jul 2008
Views:23,684
Bookmarked:20 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
9 votes for this article.
Popularity: 4.31 Rating: 4.52 out of 5

1
1 vote, 11.1%
2

3
3 votes, 33.3%
4
5 votes, 55.6%
5

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 myself.

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);
    }
}

For the EnumThreadWindows function allows Windows to 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 both Windows XP and Vista.

// 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.

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.


Member

Occupation: Software Developer
Company: Sevitec AG
Location: Switzerland Switzerland

Other popular Miscellaneous articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 18 of 18 (Total in Forum: 18) (Refresh)FirstPrevNext
GeneralAlternate Solution PinmemberEarl Waylon Flinn5:30 22 Jul '09  
GeneralRe: Alternate Solution PinmemberSimon B.11:17 28 Jul '09  
Generalwindows key VS hiding startmenu Pinmemberstillomatic10:23 24 Dec '08  
Generalcommand line Pinmemberjnelllen13:14 2 Dec '08  
GeneralAutohide PinmemberTheShadesOfGrey18:49 6 Nov '08  
GeneralHow to make this code work for .net 1.1 version Pinmembervijianand3:27 6 Aug '08  
GeneralRe: How to make this code work for .net 1.1 version PinmemberSimon B.5:26 4 Sep '08  
QuestionAnd how about Windows in other languages? PinmemberCleyton Messias8:10 1 Jul '08  
AnswerRe: And how about Windows in other languages? PinmemberSimon B.5:45 3 Jul '08  
GeneralRe: And how about Windows in other languages? PinmemberCleyton Messias7:43 3 Jul '08  
GeneralRe: And how about Windows in other languages? PinmemberSimon B.10:37 16 Jul '08  
GeneralRe: And how about Windows in other languages? PinmemberEarl Waylon Flinn5:55 27 Jul '09  
GeneralHow can i maximee the form? Pinmembermerlin.AT4:59 2 Jun '08  
AnswerRe: How can i maximee the form? PinmemberSimon B.9:26 4 Jun '08  
GeneralJust in time PinmemberKavan Shaban16:51 25 Apr '08  
GeneralRe: Just in time PinmemberSteveKing20:28 27 Apr '08  
GeneralRe: Just in time PinmemberMember 43583163:15 30 Apr '08  
AnswerRe: Hiding the start button only PinmemberSimon B.10:23 1 May '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 17 Jul 2008
Editor: Sean Ewington
Copyright 2008 by Simon B.
Everything else Copyright © CodeProject, 1999-2009
Web17 | Advertise on the Code Project