![]() If this is the situation that you're in then you'll need to add more details to your question describing what types of applications should and should not actually end the program. In such a case you will need to just hide your main form rather than closing it, but you'll need to add in some sort of mechanism that will actually close the main form when you really do want your app to end. If you want to be able to have the user click the "x" for your main form, but have another form stay open and, in effect, become the "new" main form, then it's a bit more complicated. If you are showing them again, then hiding them may be fine. As for all of the other forms, if you don't intend to show that same instance of the form again you just just let them close, rather than preventing closure and hiding them. That said, there might be some platform dependent function that can do it. By not canceling that event and just letting them form close when the user closes it you will get your desired behavior. A standard C++ program can run without a console window and instead read and write the IO to files, or elsewhere depending on the how the user wants to run it. START - Run a program, command or batch file. CALL - Call one batch program from another. EXIT - Use this to close a CMD shell and return. CMD Shell - Tips on working in the Windows CMD shell. If your entire application should always fully terminate whenever your main form is closed then you should just remove that form closed handler. CMD /c ''c:\Program Files\demo1.cmd' & 'c:\Program Files\demo2.cmd'' Those who can command themselves, command others Hazlitt. The entire application will end when the main form (the form started via Application.Run in the Main method) is closed (not hidden). Does that affect how my application is behaving now? whenever my forms call the formclosed or form closing event I close the applciation with a this.Hide() function. Reference: Why would Application.Exit fail to work?īy the way. If true, then Run has been called and you can assume that a WinForms application is executing as follows. You can determine if .Run has been called by checking the .MessageLoop property. Environment.Exit, points towards a good tip: This is the code to call when you are using console application. Terminates this process and gives the underlying operating system the specified exit code. This is the code to use if you are have called Application.Run (WinForms applications), this method stops all running message loops on all threads and closes all windows of the application. Informs all message pumps that they must terminate, and then closes all application windows after the messages have been processed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |