Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C++

Hide the Start Buttton and Desktop (Fun with Spy++)

2.32/5 (15 votes)
7 Sep 20073 min read 1   1.5K  
Using this applicatin you can hide the Start Button, System Clock, Quick Launch and much more. You can also Change the Text on Start Button.

Introduction

I have written this article for the beginner programmer who have just started programming in VC++. Most of them are not aware of the tools come with VC++. I know that because I am also the novice player here(Just 3 months) and wasn't aware of these tools before.
I will show you the little bit use of Spy++(tool) and how we can have fun with it. I have used this tool to get the handle of Start Button and Desktop.
Using my application you will be able to do the following things.

      1. Hide/Show the Start Button
      2. Hide/Show the System Clock
      3. Hide/Show the Quick Lunch
      4. Hide/Show the Tray Icons
      5. Hide/Show the Desktop and Much More...
      6. Change the Caption of Start Button (Win Xp Only, Not Working in Win2000)

Background

I have used two functions from Win32 API. They are as below. If your not aware of that please check it in MSDN for Help

  1. FindWindow()
  2. FindWindowEx().

Using the Spy++

If you are well aware of SPy++ you can directly jump to next topic.
Spy++ is one of the tools that comes with Visual Studio. So if you still haven't seen it, start your Visual Stdio and open Spy++ from Tool menu.
Its a vary nice tool through which you can retrieve the information about any window which is currently running. Information means Handle of the window, handle of its next and parent window, Its style, Class name, Process Id and much more.

I am using spy++ to retrieve the handles of Start Button,Quick Launch, System Clock etc...

Here I will show you how to use the tool to find the handle of any currently running window or control.

For Example say you have to find the handle of Start Button(Control).Actually we can directly watch the handle of Start Button in Spy++, but we can't use this because it is in digits. But we can retrieve the handle of this using its class name and the function I mention above. Here is what you can do to retrieve the Handle of Start Button.

  1. As we all know to retrieve the handle of any Control we need to have the Handle of its parent window. But how can we find out which is the parent window of Start button ? easy ! using Spy++.
  2. Open the Spy++ and open Find (Only Find not Find Window). Then drag the Finder on Start Button and press OK. On pressing OK you will be directed to the Tree List View. Where you will be able to Find which is the parent of Start Button. It will be Shell_TrayWnd.
  3. Now right click on the Shell_TrayWnd and open properties. There you will Find its Class name.
  4. Use that class name and Function FindWindow() to Find the handle of Shell_TrayWnd
  5. Then use the above handle, Class name of Start Button in the function FindWindowEx() to retrieve the handle of Start Button.

Using the code

Here I can hope that you are able to use the Spy++. If not please read the previous topic.

Below is the lines of code will retrieve the handle of start button which is the control under Shell_TrayWnd. I have retrieved the class names of Start Button and its parent window using Spy++.

HWND hStart,hTray; //Handle for Tray Window and Start Button

//This will retrieve the handle of Tray Window from its class name
hTray = ::FindWindow(L"Shell_TrayWnd", NULL);

 if(hTray)
 {
  //This will retrieve the Handle of Start Button using the above
  // handle and class name of  start Button.
      hStart = ::FindWindowEx( hTray, NULL, L"Button", NULL);
  }

Below is the lines of code I have used to Hide the Start Button and to Change the its Text (Caption).

C++
  ShowWindow(hStart,FALSE);//To Hide Start Button
  ShowWindow(hTray,TRUE);  //To Show Start Button back

//Below lines of code is to Change the Caption of Start Button
 WCHAR Text[10];
 To retrieve the Text from Edit Box
 GetDlgItemText(hWndDlg,IDC_StartTxt,Text,10);
 //Will set the text of Start Button
 //Not Working in Win2000. but Working in WinXp.
 SendMessage(hStart,WM_SETTEXT,0,(LPARAM)Text);

You can Even Directly Use the Handle

After Submitting the article I come to know that you can even Directly use the handle, you find with Spy++.

For exapmle When you will Find the handle of Start button it will look like this 00020048. Its a Hexadecimal value. You can use the followind line of code to assign it to HWND.

HWND hStart = (HWND)0x00020048; // Will assign the handle
ShowWindow(hStart,FALSE); //To Hide the Window;
ShowWindow(hStart,TRUE);//To Show Window nack;

Thanx for Reading the article. This is my second article to Code Project. So please tell how I have explained the article, anything you think about this. And if you like it please vote it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here