Click here to Skip to main content
12,549,230 members (45,113 online)
Click here to Skip to main content
Add your own
alternative version


55 bookmarked

Manipulating The Windows Taskbar

, 11 Apr 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
Some useful messages for manipulating the Windows Taskbar
Sample screenshot


Most often when visiting VC++ forums, we see questions like how to show the ShutDown dialog, Logoff dialog, how to lock the windows taskbar and others. Hence it quite fascinated me to try out a few things with the windows taskbar. The article is a result of this fascination. :)

Well this article is for those who don't know how to do this. This article simply lists the message numbers which when sent to the taskbar makes it do something (so don't expect too much). ;)

How I Did This

Well I started off by posting a few messages to the taskbar. I started off from Zero. It was a long and tedious process. The process was like:

  1. Post a message
  2. Then wait
  3. If nothing happens, post another
  4. If something happens, jot it down. Hehe

I know this is quite trivial, but anyway, this is how I did it. :)

The Message Numbers

Heh, now let me show you the real content of this article...

Note: I am using WM_COMMAND and the message number goes into the WPARAM parameter.

Serial. Msg Number Description Of The Message
1. 305 Displays the Start menu
2. 401 Displays Run Dialog
3. 402 Displays Logoff Dialog
4. 403 Command to cascade all toplevel windows
5. 404 Command to Tile Horizontally all top level windows
6. 405 Command to Tile Vertically all top level windows
7. 407 Shows the desktop. Do look at message number 419.
8. 408 Shows the Date and Time Dialog
9. 413 Shows taskbar properties
10. 415 Minimize all windows
11. 416

Maximize all windows. To see the effect of this command first do Minimize and then Maximize all.

12. 419 Well I am a bit confused about this message. This also shows the desktop. Maybe somebody can notice the difference.
13. 420 Shows task manager
14. 421 Opens Customize Taskbar Dialog
15. 424 Locks the taskbar
16. 503 Opens Help and Support Center Dialog
17. 505 Opens Control panel
18. 506 Shows the Shutdown computer dialog
19. 510 Displays the Printers and Faxes dialog
20. 41093 Displays Find Files Dialog
21. 41094 Displays Find Computers Dialog

Always on top attribute (Added on 4/12/2007)

Recently a guy asked me how to remove always on top attribute from the taskbar. So I thought of adding the piece of code that does this...

Msg Id is 0x02b1 WPARAM 0x7 -- Taskbar always on top
Msg Id is 0x02b1 WPARAM 0x8 -- Taskbar normal.

// Set task taskbar always on top
::SendMessage(hShellWnd, 0x2b1, 7, 0);
::SendMessage(hShellWnd, 0x581/*WM_USER+385*/, 1, 0);
::SendMessage(hShellWnd, 0x550/*WM_USER+336*/, 0, 10001);

// Set taskbar always on top off
::SendMessage(hShellWnd, 0x2b1, 8, 0);
::SendMessage(hShellWnd, 0x581/*WM_USER+385*/, 1, 0);
::SendMessage(hShellWnd, 0x550/*WM_USER+336*/, 0, 10001);
::SendMessage(hShellWnd, 0x579/*WM_USER+377*/, 0, 0);

The Code that Sends the Message...

I know most of you know how to do this, but for beginners this could be tough. So hence here it is...

UINT nEventIds[] =
 305,        //DisplayStartupMenu
 401,        //DisplayRunDialog
 402,        //DisplayLogoffDialog
 403,        //ArrangeCascade
 404,        //ArrangeTileHrz
 405,        //ArrangeTileVrt
 407,        //ShowDesktop
 408,        //ShowDateTimeDialog
 413,        //ShowTaskbarPrps
 415,        //MinAll
 416,        //MaxAll
 419,        //ShowDesktop2
 420,        //ShowTaskMngr
 421,        //TaskBrCustomizeNtfy
 424,        //LockTaskbar
 503,        //HelpAndSuppCenter
 505,        //ControlPanel
 506,        //TurnOffCompDialog
 510,        //PrintersAndFaxesDialog
 41093,      //FindFilesDialog
 41094       //FindComputers

// Does initialization, adds strings to combo based on 
// based on the above array.

void CHackTrayDlg::Init(void)
  m_cCmbEventList.AddString(_T("Start menu"));
  m_cCmbEventList.AddString(_T("Run dialog"));
  m_cCmbEventList.AddString(_T("Log off dialog"));
  m_cCmbEventList.AddString(_T("Cascade windows"));
  m_cCmbEventList.AddString(_T("Tile windows horizontally"));
  m_cCmbEventList.AddString(_T("Tile windows vertically"));
  m_cCmbEventList.AddString(_T("Show desktop"));
  m_cCmbEventList.AddString(_T("Date time dialog"));
  m_cCmbEventList.AddString(_T("Task bar properties"));
  m_cCmbEventList.AddString(_T("Minimize all"));
  m_cCmbEventList.AddString(_T("Maximize all"));
  m_cCmbEventList.AddString(_T("Show desktop 2"));
  m_cCmbEventList.AddString(_T("Show task manager"));
  m_cCmbEventList.AddString(_T("Task bar customize notifications")); 
  m_cCmbEventList.AddString(_T("Lock taskbar"));
  m_cCmbEventList.AddString(_T("Help and support center"));
  m_cCmbEventList.AddString(_T("Control panel"));
  m_cCmbEventList.AddString(_T("Turn off computer dialog"));
  m_cCmbEventList.AddString(_T("Printers and faxes dialog"));
  m_cCmbEventList.AddString(_T("Find files dialog"));
  m_cCmbEventList.AddString(_T("Find computers")); 

//Code for posting messages to the taskbar
void CHackTrayDlg::OnCbnSelendokCombo1()
  int selIndex = m_cCmbEventList.GetCurSel();
  if(selIndex != CB_ERR)
    static HWND hShellWnd = ::FindWindow(_T("Shell_TrayWnd"), NULL);
    if(hShellWnd != NULL)
       ::PostMessage(hShellWnd, WM_COMMAND, MAKELONG(nEventIds[selIndex], 0), NULL); 
       hShellWnd = ::FindWindow(_T("Shell_TrayWnd"), NULL); 

Watch Out

You might have noticed the huge gap between the last few messages. I didn't find any in between this. I think there might be some but maybe I didn't notice it. For example, the Lock statusbar message number. Initially I didn't notice the difference but when I tried to resize the taskbar LOL then I realised something had happened. Heh I was quick to retest the whole thing to find out which message number caused the event.

How Can You Help Me

Well if you know of any other messages, please tell me. I will post them here along with the others.


I don't know how reliable this information is. Well all of them work in WinXP and 2000. Please test the above information before using it. The author does not take any responsibility for any kind of damage caused due to this article. Please use this at your own risk.


  • Modified on 4/12/2007 (Added code for removing always on top attribute from taskbar)


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


About the Author

Nibu babu thomas
Software Developer Microsoft
India India
My Technical Blog

I am a computer programmer who started his career as a Java programmer in 2000. Wrote a game and several applications like editors, DB apps etc in Java. My fascination for programming went on a high in the following years. I did a post graduate diploma of 2 years because of which I got introduced to a plethora of Languages. My favorite at that time was VB because it was way too easy to program, intelli-sense was too cool.

I joined an NGO in 2002 as part time computer programmer. Primary responsibility was to develop their website and to write apps for them in VB. During this process I got introduced to DHTML, CSS, HTML, JavaScript, wow had hell of a time. Learned and learned and learned during this time. I got into Visual C++ because of my post graduation in computer applications. I was forced into this powerful language but how lucky I am. Initially I was scared of CreateFont API Wink | ;) but now its a piece of cake. Smile | :)

As of now I'm working as Visual C++ engineer with Microsoft. My passion for this language never ends. Its the raw power of the language, the kind of performance and flexibility it provides, that keeps me motivated to continue working in this language. Started working in VC6 and all through till the latest version of Visual C++. Smile | :)

I'm part of the Microsoft Developer Support - Programming Languages Team. Enjoying every day.

You may also be interested in...

Comments and Discussions

Jokeresource hacker Pin
FatassCartmaN26-Jul-10 11:22
memberFatassCartmaN26-Jul-10 11:22 
General5000 shows the "Switch User" dialog under 7/Vista/XP Pin
Jochen Baier3-Feb-10 5:24
memberJochen Baier3-Feb-10 5:24 
General517 locks desktop under Vista and 7 [modified] Pin
Jochen Baier3-Feb-10 5:07
memberJochen Baier3-Feb-10 5:07 
Questionalways on top on/off Pin
lengfy4-Feb-09 21:33
memberlengfy4-Feb-09 21:33 
AnswerRe: always on top on/off Pin
virusak39-Mar-09 7:17
membervirusak39-Mar-09 7:17 
GeneralA little more information Pin
whelkpeddle16-Nov-08 22:16
memberwhelkpeddle16-Nov-08 22:16 
GeneralPathetic : copy-paste of usenet post from... 1999 Pin
kilt24-Jul-08 19:57
memberkilt24-Jul-08 19:57 
GeneralRe: Pathetic : copy-paste of usenet post from... 1999 Pin
Nibu babu thomas24-Jul-08 20:01
memberNibu babu thomas24-Jul-08 20:01 
GeneralRe: Pathetic : copy-paste of usenet post from... 1999 Pin
Flave7-Nov-09 10:37
memberFlave7-Nov-09 10:37 
GeneralRe: Pathetic : copy-paste of usenet post from... 1999 Pin
Nibu babu thomas8-Nov-09 19:18
memberNibu babu thomas8-Nov-09 19:18 
GeneralListen if Startmenu opened Pin
danielku1523-May-08 7:15
memberdanielku1523-May-08 7:15 
QuestionHow to catch the event when some new program starts? Pin
ebody19-May-08 1:45
memberebody19-May-08 1:45 
GeneralVISTA... Pin
TalSt7-Apr-08 20:15
memberTalSt7-Apr-08 20:15 
GeneralRe: VISTA... Pin
Nibu babu thomas7-Apr-08 20:20
memberNibu babu thomas7-Apr-08 20:20 
GeneralRe: VISTA... Pin
TalSt7-Apr-08 21:07
memberTalSt7-Apr-08 21:07 
GeneralRe: VISTA... Pin
Nibu babu thomas7-Apr-08 21:24
memberNibu babu thomas7-Apr-08 21:24 
GeneralIts Really Great Pin
Hiran Das18-Aug-06 4:41
memberHiran Das18-Aug-06 4:41 
GeneralWell done! Pin
AndrewVos15-Aug-06 23:22
memberAndrewVos15-Aug-06 23:22 
GeneralRe: Well done! Pin
Nibu babu thomas15-Aug-06 23:49
memberNibu babu thomas15-Aug-06 23:49 
GeneralRe: Well done! Pin
AndrewVos16-Aug-06 1:21
memberAndrewVos16-Aug-06 1:21 
GeneralRe: Well done! Pin
Nibu babu thomas16-Aug-06 17:22
memberNibu babu thomas16-Aug-06 17:22 
GeneralRe: Well done! Pin
AndrewVos16-Aug-06 22:53
memberAndrewVos16-Aug-06 22:53 
GeneralRe: Well done! Pin
Nibu babu thomas17-Aug-06 17:28
memberNibu babu thomas17-Aug-06 17:28 
GeneralCode in C# Pin
Drew Noakes9-Aug-06 2:47
memberDrew Noakes9-Aug-06 2:47 
GeneralRe: Code in C# Pin
Nibu babu thomas9-Aug-06 17:12
memberNibu babu thomas9-Aug-06 17:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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
Web02 | 2.8.161021.1 | Last Updated 12 Apr 2007
Article Copyright 2006 by Nibu babu thomas
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid