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?