Results 1 to 17 of 17

Thread: [RESOLVED] Closing a windowed app with the "X"

  1. #1

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Resolved [RESOLVED] Closing a windowed app with the "X"

    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..:


    Thanks
    - ØØ -
    Last edited by NoteMe; Jul 24th, 2005 at 05:23 PM.

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: Closing a windowed app with the "X"

    Form.Closing
    you will need to override WndProc to figure out why it's being closed
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Closing a windowed app with the "X"

    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... ..



    - ØØ -

  4. #4
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Closing a windowed app with the "X"

    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.

  5. #5

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Closing a windowed app with the "X"

    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:

    Code:
    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...


    - ØØ -

  6. #6
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Closing a windowed app with the "X"

    Why not just handle the exception when the device is lost? You won't have to do any checking at all then.
    I don't live here any more.

  7. #7

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Closing a windowed app with the "X"

    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..



    - ØØ -

  8. #8
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Closing a windowed app with the "X"

    Why is it slow? It doesn't come into effect until an error has occured anyway.

    Databases are for møøses.
    I don't live here any more.

  9. #9

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Closing a windowed app with the "X"

    Quote Originally Posted by wossname
    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.

  10. #10
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Closing a windowed app with the "X"

    Shut up about databases. We agree that they suck.

    What pipeline?
    I don't live here any more.

  11. #11

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Closing a windowed app with the "X"

    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...

    - ØØ -

  12. #12
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Closing a windowed app with the "X"

    Why not just remove the "X" button Controlbox = false, or set the border to borderless.
    I don't live here any more.

  13. #13

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Closing a windowed app with the "X"

    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...


    - ØØ -

  14. #14
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Closing a windowed app with the "X"

    What's wrong with fullscr...*SLAM*
    I don't live here any more.

  15. #15

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Closing a windowed app with the "X"

    Quote Originally Posted by MrPolite
    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..




    - ØØ -

  16. #16
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: Closing a windowed app with the "X"

    Quote Originally Posted by NoteMe
    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
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  17. #17

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: [RESOLVED] Closing a windowed app with the "X"

    Not actualy. As long as "device".present() is not throwing an exception because of a lost device I am fine..


    Thanks for your help.
    - ØØ -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width