I have this winform app that tracks battery life, if I close the app during an "alt+tab" (like in the pic below) it closes the app completely.
I want to program the close button (if this is possible) to minimize the app to the system tray instead of closing it completely.
I have not seen any similar solutions for this, all I see is disabling the alt+tab on a winforms app.
I want to do this because if I close the app the battery percentage wont be monitored anymore, I just want to know if this is possible though.

FormClosingevent as shown in the linked question and sete.Cancelto true after checking any validation logic you need. Make sure not to prevent closing ife.CloseReason == CloseReason.WindowsShutDownso that your program doesn't interrupt the shutdown process. - 41686d6564