How do you cancel an EVENT_APPTERMINATE
BlitzMax Forums/BlitzMax Programming/How do you cancel an EVENT_APPTERMINATE
| ||
I'm trying to check the EVENT_APPTERMINATE in my main game loop and then if its true, I want to change my gamestate to an exit value. Then on the next pass, I can clean up and exit smoothly and offer the user a messagebox to cancel the EVENT_APPTERMINATE. So my question is how do you cancel the event, so it doesn't go and destroy my window? If this isn't clear enough, what I'm trying to do is give the user the opportunity to decide if they really want to quit the game. In VB6, you could trap for the event and then just set Cancel=True and it would act as if nothing had ever happened. Anyone have any ideas? |
| ||
I hope I have understand you right. |
| ||
Thanks for your help klepto2. What you're saying makes sense, and I can run the code you provided with the desired outcome. However, in my code(and I'm using IGlass) what happens is that as soon as the person clicks the close button, the window disappears and is no longer in the tray at the bottom. Then the messagebox appears on top of the desktop. If I choose "yes" the program stops execution. If I choose "no" the program is still running but my desktop doesn't come back. Something else I noticed was that the cursor goes behind the messagebox, but the clicks register when you click over the buttons. If anyone has any other thoughts, please let me know. Thanks |
| ||
For the thing, with the fullscreen issue is right, for this you have to make it via IGLass and then maybe like this:Graphics 800,600,32,-1 Global EndApp:Byte = False Repeat If (AppTerminate() = True Or KeyHit(Key_Escape) = True) And EndApp = False Then EndApp = True EndIf If EndApp = False Then DrawText "This is a Test",20,20 Else GetEndRequest() EndIf Flip Cls Forever Function GetEndRequest() DrawText "Really Quit !",400,300 DrawText "(Y)es or (No)",400,320 If KeyHit(Key_Y) Then End If KeyHit(Key_N) Then EndApp = False EndIf End Function instead of the DrawText commands you could use the IGlass things. |
| ||
Thanks again klepto2. I still couldn't get your code working in my app, but I knew it should work. So I finally found the culpret. This line was causing the issue: SetGraphicsDriver GLMax2DDriver() I removed it from my setup code and everything is fine now. I don't know if this is a bug or not, but it was definately the problem. Now I can trap everything correctly. As soon as I put it back in, I get the same problems again. Go figure. Thanks for all your help. |