Click here to Skip to main content
13,254,366 members (60,504 online)
Click here to Skip to main content
Add your own
alternative version


74 bookmarked
Posted 29 Oct 2003

Minimize any window to system tray using Windows Hook

, 29 Oct 2003
Rate this:
Please Sign up or sign in to vote.
If there are some applications you have to run during your work, but need to minimize them to the Task Bar, make your Task Bar become "dirty". This utility will minimize them to the System Tray.


There're times when your desktop becomes "dirty" because there're many applications running. Among them, there're some you have to let run during your work (E.g.: I have to let the MS Outlook run all the time). If you minimize them, they will make your task bar crowded. I chose to minimize them to the system tray for my own convenience. So, I decided to write a tiny utility to make all windows minimized to the system tray.

How To?

To solve my problem, I have to answer the following questions:

  1. How to make a particular window be minimized to the system tray?
  2. How to make any window to accept my command (minimized it to system tray)?

The first question is not very difficult. There're many articles about this topic. The second question is not very difficult either. I just use Windows Hooks to intercept some Windows messages when a window menu (system menu) of a window is being displayed, then I append a menu item of my own into this window menu. When a user choose this menu item, Windows will send a message to that hooked application, I intercept this message again, and minimize the application to the system tray. When a user clicks on an icon in the system tray of a hooked application, Windows will send a message to that application, I intercept this message again, and restore that application window, and remove its icon from the system tray. That's all. I have commented so much in my source code, so you can read and understand it easily.

Open Issues

  1. When you exit or disable this utility while there is any application minimized to the system tray, those application will not be restored properly, you must restore all hooked applications before you exit or disable this utility. I'll fix this defect in future, but if someone has any idea about this issue, please share it with me.
  2. If you find any improvement or suggestion, please let me know.

Thank you for reading my article!


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


About the Author

Chau Nguyen
Web Developer
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

Generalanybody know how to track clicks to the upper left icon Pin
RogerPack30-Mar-09 10:52
memberRogerPack30-Mar-09 10:52 
GeneralRe: anybody know how to track clicks to the upper left icon Pin
RogerPack7-Apr-09 11:36
memberRogerPack7-Apr-09 11:36 
GeneralRe: anybody know how to track clicks to the upper left icon Pin
RogerPack23-Apr-09 9:20
memberRogerPack23-Apr-09 9:20 
QuestionCan I handle events other than "Tray Me"? Pin
'¯`°²¤ zee ¤²°`¯'6-Sep-07 13:51
member'¯`°²¤ zee ¤²°`¯'6-Sep-07 13:51 
Generaljust what I wanted. Pin
guoxu31-Aug-07 16:54
memberguoxu31-Aug-07 16:54 
GeneralThx Pin
xgo20-Mar-07 3:28
memberxgo20-Mar-07 3:28 
GeneralWindow movement restriction Pin
AKG20-Feb-07 22:59
memberAKG20-Feb-07 22:59 
GeneralThanks Pin
mike34711-Feb-07 22:53
membermike34711-Feb-07 22:53 
GeneralSimple and Neat Pin
SRV_Bala27-Sep-06 2:38
memberSRV_Bala27-Sep-06 2:38 
GeneralAdds multiple "Tray Me" entries [modified] Pin
gondola7-Aug-06 13:02
membergondola7-Aug-06 13:02 
GeneralThankyou Pin
rimblock18-Jul-06 15:02
memberrimblock18-Jul-06 15:02 
GeneralThank you! Pin
chick8031-May-06 23:57
memberchick8031-May-06 23:57 
GeneralC# Example Pin
XWreckage24-May-06 7:39
memberXWreckage24-May-06 7:39 
General"Free minimized windows" suggestion Pin
anat0lik15-May-06 5:55
memberanat0lik15-May-06 5:55 
GeneralRe: "Free minimized windows" suggestion Pin
RogerPack7-Apr-09 11:39
memberRogerPack7-Apr-09 11:39 
GeneralRequires two clicks with many apps like IE, etc Pin
rxxs1-Aug-05 15:22
sussrxxs1-Aug-05 15:22 
QuestionNot working with XP Media Center Edition? Pin
tiecoon4-Jun-05 9:44
membertiecoon4-Jun-05 9:44 
GeneralNovell GroupWise Pin
meink15-Mar-05 12:20
membermeink15-Mar-05 12:20 
QuestionWhy doesn't it work with CMD windows? Pin
Rabbej12-Feb-05 4:41
memberRabbej12-Feb-05 4:41 
AnswerRe: Why doesn't it work with CMD windows? Pin
nosek13-Dec-05 4:58
membernosek13-Dec-05 4:58 
GeneralRe: Why doesn't it work with CMD windows? Pin
kalantir12-Nov-07 21:53
memberkalantir12-Nov-07 21:53 
GeneralCan't compile code Pin
ShomBando29-Dec-04 13:38
memberShomBando29-Dec-04 13:38 
GeneralNot working properly in Win98 Pin
Somersault606-Dec-04 5:23
memberSomersault606-Dec-04 5:23 
QuestionHow do I use this App Pin
Franklin577527-Jan-04 5:38
memberFranklin577527-Jan-04 5:38 
AnswerRe: How do I use this App Pin
Ash Lux18-Apr-04 17:35
memberAsh Lux18-Apr-04 17:35 
GeneralNice work, one suggestion Pin
Vasko3-Nov-03 22:28
memberVasko3-Nov-03 22:28 
GeneralRe: Nice work, one suggestion Pin
Chau Nguyen3-Nov-03 22:48
memberChau Nguyen3-Nov-03 22:48 
Generalproblem Pin
thienle31-Oct-03 15:12
memberthienle31-Oct-03 15:12 
GeneralRe: problem Pin
Matt G5-Nov-03 1:40
memberMatt G5-Nov-03 1:40 
GeneralRe: problem Pin
avenger_sb2531-Mar-04 9:11
memberavenger_sb2531-Mar-04 9:11 
QuestionDirty? Pin
NGS 54967230-Oct-03 6:32
memberNGS 54967230-Oct-03 6:32 
AnswerRe: Dirty? Pin
Chau Nguyen30-Oct-03 15:26
memberChau Nguyen30-Oct-03 15:26 
AnswerRe: Dirty? Pin
Cristian Amarie3-Nov-03 20:34
memberCristian Amarie3-Nov-03 20:34 
GeneralRe: Dirty? Pin
Chau Nguyen3-Nov-03 21:58
memberChau Nguyen3-Nov-03 21:58 
GeneralHaving problems with IE Pin
Darren_vms30-Oct-03 1:49
memberDarren_vms30-Oct-03 1:49 
GeneralRe: Having problems with IE Pin
Chau Nguyen30-Oct-03 15:15
memberChau Nguyen30-Oct-03 15:15 
GeneralEasy Way Pin
M Aamir Maniar30-Oct-03 0:49
memberM Aamir Maniar30-Oct-03 0:49 
GeneralRe: Easy Way Pin
Sven Axelsson30-Oct-03 3:51
memberSven Axelsson30-Oct-03 3:51 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171114.1 | Last Updated 30 Oct 2003
Article Copyright 2003 by Chau Nguyen
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid