1

I have a Console application which I want to minimize to System tray. I have implemented it by calling Windows APIs (User32.dll and Kernel32.dll) and NotifyIcon and its working fine. Once the Console app starts, it shows the console window for couple of seconds and then automatically minimizes it to System tray. It also restores the minimized window back by clicking on the Restore item from the Context Menu on NotifyIcon but the only issue I am facing is, after restoring when I try to minimize it back to tray by clicking on the window Minimize button ( [-] ) it does not minimize it to the tray, instead it minimizes it to task bar. This is happening because I have not handled the console window minimize button click action and I am not able to do so.

Could anyone please share the code to handle Console Window minimize and maximize button click action?

rene
  • 41,474
  • 78
  • 114
  • 152
Mayuri B
  • 19
  • 1
  • 1
    Why do you use Console application if you want desktop application (namely tray support) functionality? – Sinatr Mar 29 '17 at 10:16
  • If you really need that, then one way is to [get console window handle](http://stackoverflow.com/q/1277563/1997232) and [hook wndproc](http://stackoverflow.com/q/9665579/1997232) to handle [`WM_SIZE`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms632646(v=vs.85).aspx). – Sinatr Mar 29 '17 at 10:22
  • That's the existing application already in use at customer location and this is a new enhancement(hide to system tray) to it so don't want to change/disturb its type – Mayuri B Mar 29 '17 at 10:57

0 Answers0