Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Handling Program Exit

Author
Message
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 1st Jul 2011 11:43 Edited at: 1st Jul 2011 11:45
Ok, this sounds trivial, but it's causing a problem with my app. If I close the game window by hitting the [X] button in the corner, the app shuts down but 'crashes'; it says that the app has encountered an error and needs to close.

However, when the player hits Spacebar - and the app goes through the normal shutdown sequence - the program does not crash.

My code is structured as such:


I'm using Nuclear Glory, so I think the problem has to do with the system not being able to clean up and exit correctly. Any advice?
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 1st Jul 2011 13:00
Hi, what you could do is run your program in full screen mode or put SET WINDOWS OFF command at the beginning of your program which will run the program at fullscreen which hides the 'X' button at the top.

One other theory I have is to check if your app is running via the EXECUTABLE RUNNING() command and if it equals 0 initiate your clean up sequence. I have no idea if this will work though.

Good luck

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 1st Jul 2011 13:01
There is a way to remove the X from the window, maybe that will help? I'm sure there's also a way to disable the function of the X button, and then redirect it into the code, though I don't know how...

TheComet

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 1st Jul 2011 16:29
DBP does tons of cleanup itself, generally there's no need to worry. If you're calling/using dll's then you may have to add the extra cleanup stuff.

The only real cleanup I do is if I am resetting the program and going back to another point in it without exiting and freeing up unused resources.

Warning! May contain Nuts!
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 1st Jul 2011 19:20
@WLGfx
I'm aware of this fact. I'm already taking care of some cleanup when the user programatically exits the program. Everything gets cleaned up and ends normally. HOWEVER, I cannot perform this cleanup when the user [X] out of the window. When this happens, the application crashes.

Thus, that's why I was asking how I can perform these cleanup actions when the user closes the window.
Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 1st Jul 2011 20:08
You can use the BBB Gui plugin. When you start it, the window will not close when you press the [X] button. This way you can manually check if the [X] button is pressed, then do your cleanup and exit the program.
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 1st Jul 2011 20:12
IanM's Matrix 1 plugin set contains commands to do this.

first bit...


next bit...


and then with your functions


This is how I do it anyway.

Hope that helps

anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 1st Jul 2011 23:54
=Prof= you are a god among men
Thank you!
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 2nd Jul 2011 00:08
awesome Prof!


Why does blue text appear every time you are near?
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 2nd Jul 2011 00:50
No probs, lol :$

But the kudos should really go to IanM and his Matrix1 plugin set

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 2nd Jul 2011 16:31
Ah ha... It's also nice to know that you can catch the WinAPI message queue too with the callback function.

Thanks for putting that up...

Warning! May contain Nuts!

Login to post a reply

Server time is: 2026-07-10 15:31:28
Your offset time is: 2026-07-10 15:31:28