Introduction
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:
- Post a message
- Then wait
- If nothing happens, post another
- 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.
::SendMessage(hShellWnd, 0x2b1, 7, 0);
::SendMessage(hShellWnd, 0x581, 1, 0);
::SendMessage(hShellWnd, 0x550, 0, 10001);
::SendMessage(hShellWnd, 0x2b1, 8, 0);
::SendMessage(hShellWnd, 0x581, 1, 0);
::SendMessage(hShellWnd, 0x550, 0, 10001);
::SendMessage(hShellWnd, 0x579, 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, 401, 402, 403, 404, 405, 407, 408, 413, 415, 416, 419, 420, 421, 424, 503, 505, 506, 510, 41093, 41094 };
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"));
}
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);
else
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.
Disclaimer
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.
History
- Modified on 4/12/2007 (Added code for removing always on top attribute from taskbar)