I’ve discovered how to disable the “OK” button in my Windows Mobile application (by setting ControlBox to false).
The problem I had was that it was possible for me to close my application by pressing this “OK” button, but the FormClosing, FormClosed events were not fired, and most worrying, the form’s Dispose() method was not called either. This made it quite difficult to clean up things like threads and other resources.
Now that I can force the user to use my own “Quit” button, those methods all get executed as I would expect.
Question: why does the “OK” button in a Windows Mobile application close the application while bypassing the methods I mentioned?
When you wrote the code for the
FormClosingandFormClosedevents, did you remember to wire the actual form up to use these?I have a few Windows Mobile applications that I maintain, and they call the methods I created for them.
I often forget to set the Controls to use the code that I write for them, so that was the first thing I thought of.
EDIT: I do not use Microsoft’s
OKbutton, but instead make use of a Menu that has an EXIT Menu Item.I also turn off the Soft Input Panel (SIP) and Task Bar by P/Invoking the “coredll” file in the
Program.csfile before my main program executes.That may be a solution for you. If so, this should be all of the code I use for that. Be sure to test it, and if something is missing, let me know and I’ll update it.