Closing a console window.
BlitzMax Forums/BlitzMax Programming/Closing a console window.
| ||
Hi! :) Is there any way to see when the user closes your console application with the 'X'? Thanks! |
| ||
appTerminate() ? |
| ||
Tried that, doesn't seem to do the trick :/ |
| ||
Tried that, doesn't seem to do the trick :/ How did you use it? The AppTerminate function checks to see whether the close button was pressed or not. You should be checking if AppTerminate() = True, and ending the program if it is.I have not checked if AppTerminate does respond to the close button on console windows, but it should. |
| ||
AppTerminate() only checks for the window close gadget being clicked - you need to tell it what to do, ie:Repeat 'do stuff Until AppTerminate() End [edit] Oh wait - a console window? I'm not sure on that one but I suspect thats the problem. [edit again] Right, not sure what you're talking about now - a console window just closes when you click the close button without any intervening code. |
| ||
I think he wants to "hijack" when the console close button is clicked, and do something else. |
| ||
Yeah, I need to know when the user is closing the console window so I can close some sockets and other stuff. |
| ||
Have you tried OnEnd? You can attach a function to be called when the program ends using OnEnd, but I don't know if it will work with win32 consoles. |
| ||
Yeah, Tried both OnEnd and AppTerminate and neither seems to work :/ |
| ||
Try putting something in the Delete() method of a type? |
| ||
Doesn't work either :/ |
| ||
Surely there must be some way? I don't want to have to use MaxGUI or a Graphics window >.< |
| ||
No one? :( |
| ||
Console windows technically aren't windows. They are programs themself (on windows the cmd application, on osx the terminal) I guess thats why you don't get any window events |
| ||
you could make it into a windows service? |
| ||
Perhaps you could make an invisible program that then calls this console program? |
| ||
Thanks for your answers, how does one go ahead and make the program into a windows service? @Czar Flavius I'd rather not do it that way, thanks for the suggestion though ^^ |