Hello,
I have created a fatal error function that displays text passed to it via MessageBox, and then shuts down the application. I am having problems with MessageBox's tendency to be concurrent. Since the program flow continues after the message box is displayed, the application is shut down immediately, before the user has a chance to read the message, or click 'ok' to close it.
If I grab the result returned back from MessageBox (and do something with it, so the compiler does not optimize the code out), then the program will wait for the message box to close, as the program flow cannot continue on without this piece of information.
(EDIT: Since more than a few have been confused by the above, I am going to point out that the code that is 'optimized out' is NOT the function call, but the variable that stores the result of the function, which is not used for any other reason. The compiler knows that this variable is useless, and therefore does not even reserve space in memory for it. I hope this clears up my comment. )
So, I have a few questions:
1. Where is all of this documented? I cannot find any information from MSDN's documentation on MessageBox.
2. Is it possible to force the program flow to wait for a message box to terminate without adding useless junk code (that may or may not be optimized out in some future, smarter version of my compiler)?
3. Do you have any information that may help solve this problem of creating a proper fatal error function?
Any help is appreciated.