Hello Marshall,
Replacing the console window with a gui window would indeed solve the problem. Another solution would be to convert it into a daemon and writing a gui client to display the status messages.
The reason why i am not doing any of this is, that the program itself is an interim kludge for a closed source CTI (computer telephony interface) program which is used in a hotline. The hotline software fails to display basic things which one would expect of such a software, such as who is logged in, what their status is, what the call statistics are (SLA), and so on. The kludge which i quickly whipped up a few year ago, is a simple tcp proxy reading the communication between the client and the server presenting the information above through printing it to the console whenever there is any change. There is no user interaction, it just displays the infos, and it updates frequently. The users do not get the impression of it being hung.
Then why did i want to add a handler for program termination? When a user is done, they will close the windows. So far so good. If they close however the tcp proxy before the client programm, then the logoff in the client programm will never reach the server, because the tcp proxy is down. With the given cti server software the hotline agent will still be active and receive call, thus causing failed call counts to go up. Reason being that an explicit logoff is required to be removed from the hotline rotation. My intent was to inject the logoff message into the tcp stream whenever the simple tcp proxy is closed, thus eliminating the problem. But for that i would have needed a working "close" or "destroy" handler.
Since this software is supposed to be retired soon, there is no point in investing time into a major rewrite. I would have just added the logoff, if there would have been an easy way to call it upon window destruction.
If i started converting that quick and dirty kludge to a gui application, then i could immediately write a new GUI client for the CTI software, since i know enough about the protocol to do so. This would also eliminate the need for a tcp proxy. Considering however that it is a soon to be retired application with a small user base, i can not justify putting that much time into it.