5

Pretty much a self-explanatory title. I'm writing an application in C++ with the Win32 API, and I'd like to know how to minimize to the system tray. I can find all kinds of articles online about minimizing to the system tray in C#, Python, even Visual Basic, I think, but for the life of me I can not find a single article on how to minimize something to the system tray in C++.

Any and all help or even redirection would be highly appreciated.

EDIT: Question answered. Once I knew about the Shell_NotifyIcon function, I was easily able to find this CodeProject article which is exactly what I needed.

Ken Bellows
  • 6,711
  • 13
  • 50
  • 78
  • When you say minimize to the tray, do you mean just having a tray icon or do you want the minimize animation for your window to minimize down to your tray icon and not the taskbar button? – Anders Jan 30 '11 at 17:57
  • @Anders: I hadn't actually thought about the animation, but that would be pretty sweet. Any ideas on that? – Ken Bellows Jan 30 '11 at 18:42
  • 1
    SetWindowPlacement can set the minimize target, you just need to find the tray rectangle, Shell_NotifyIconGetRect does that on Win7, <=Vista you need to use FindWindow and undocumented class names – Anders Jan 30 '11 at 23:38
  • There is a missing res/dlg.manifest on the CodeProject zip file. I know this is an old thread, but can anyone provide it or point what to add/delete/change? Regards. – nephewtom Jul 31 '19 at 02:38

1 Answers1

11

All you need is the Shell_NotifyIcon function. You ought to be able to work it out from MSDN, but if you need more help I'm sure there are a million places on the web that give samples. Now that you know the name of the API, web search will fill in the gaps.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490