Click to See Complete Forum and Search --> : [RESOLVED] Closing a windowed app with the "X"
NoteMe
Jul 24th, 2005, 05:08 PM
This is a bit complicated to explain since I don't know the terms here yet. But try to understand..:)
If someone press the X in the upper left of a window. It will terminate my application. But if it is doing something at that moment, I need to tell my application to stop it. What delegate/event do I use/attach to my winform so I can use a function to end what it is doing?
[Edit]Ohhh and since I am going to bed now....please elaborate on your answer...it was not good enough..:D:D:
Thanks
- ØØ -
MrPolite
Jul 24th, 2005, 05:39 PM
Form.Closing;)
you will need to override WndProc to figure out why it's being closed
NoteMe
Jul 25th, 2005, 02:07 AM
Ehhh...hmm...ok....I should have added the Edit in bold..:)...just kidding.
OK, I think I can do that. But have to wait untill I get home tonight to test. Don't think I need to know why the app terminated. It can't be much more then the X in the upper right corner that will end it. Unless I get an unhandled exception, and that NEVER happens in my apps... :sick: ..:D
- ØØ -
wossname
Jul 25th, 2005, 04:07 AM
Just set a flag in your app that the other thread can see and periodically poll it to see when to finish. Then it can tie up any loose ends before quitting.
Is this what you mean?
Forgive me if my humble reply does not meet your exacting CERN specifications, but I am but a mere peasant in comparison to a man of your standing. :D
NoteMe
Jul 25th, 2005, 04:16 AM
Since you entered a thread too, I might explain it a bit more in detail..;)
I have a tight game loop (wohhoo..I am doing MDX now..:)). And I of course want to do minimum work to test if the device is still working. So the loop (simplified) looks like this:
while(running){
//Draw my freaking fancy stuff
}
But if someone presses the X in the upper left corner. The device will be lost. But in stead of also checking for decive.created every iteration, I want to just set running to false. So it won't try to draw when there is no device. So if the X fires an event, I guess I can do it that way.
PS: It is only one thread at the moment...:)
- ØØ -
wossname
Jul 25th, 2005, 06:44 AM
Why not just handle the exception when the device is lost? You won't have to do any checking at all then.
NoteMe
Jul 25th, 2005, 06:51 AM
Exception handling is slow..:)...it would even be faster to check for device.created....:)..thats why..:) Exception handling is for wimps with databases on their minds..:):):)
- ØØ -
wossname
Jul 25th, 2005, 06:57 AM
Why is it slow? It doesn't come into effect until an error has occured anyway.
Databases are for møøses.
NoteMe
Jul 25th, 2005, 07:20 AM
Why is it slow? It doesn't come into effect until an error has occured anyway.
Databases are for møøses.
But it is still branching right.....so it will mess up the pipeline one more time then nessesary. And you don't want that in a game loop...You can do that in a database.
wossname
Jul 25th, 2005, 07:52 AM
Shut up about databases. We agree that they suck.
What pipeline?
NoteMe
Jul 25th, 2005, 07:55 AM
The CPUs pipeline....;) With a P4 processor you have 20 pipes. And you don't want to mess with them so they all miss in a game loop..:)
BTW as an example for you. In Java exception handling is about 100 times faster then the exception handling in C++. In C# exception handling is 1000 TIMES slower then checking for an error code....:)
Exception handling is great for IO stuff and so on. Like for loading a level, but you really don't use it in a game loop. Unless you really want to buy a new SGI computer every time you make a game..:)
[Edit] Database, database, database, database, database...:)
- ØØ -
wossname
Jul 25th, 2005, 08:34 AM
Why not just remove the "X" button :D Controlbox = false, or set the border to borderless.
NoteMe
Jul 25th, 2005, 09:30 AM
Hehe...I was sooo about to say some ugly words right now..:)...I bet your next post will be "why not use full screen exclusive"...:)...no no no. But I have a feeling that the close event will work. Will give an update on it tomorrow...
- ØØ -
wossname
Jul 25th, 2005, 09:42 AM
What's wrong with fullscr...*SLAM*
NoteMe
Jul 25th, 2005, 01:18 PM
Form.Closing;)
you will need to override WndProc to figure out why it's being closed
That actualy worked....nice one chap.....:)...
this.Closing += new System.ComponentModel.CancelEventHandler(...)
was it, if I remember right..:)
- ØØ -
MrPolite
Jul 25th, 2005, 03:31 PM
That actualy worked....nice one chap.....:)...
this.Closing += new System.ComponentModel.CancelEventHandler(...)
was it, if I remember right..:)
- ØØ -
do you still need to know if the user pressed the "x" button, or if your app is being close for other reasons? I used to know how to figure it out:D
NoteMe
Jul 25th, 2005, 03:57 PM
Not actualy. As long as "device".present() is not throwing an exception because of a lost device I am fine..:)
Thanks for your help.
- ØØ -
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.