win32 'x' out window to close app?

Hi,

I’m looking for a way to call the exit callback once someone hits the ‘X’ button on the main window. I was thinking to add:

  
void testApp::update(){  
	if(!glutGetWindow())  
		OF_EXIT_APP(0);  
...  
  

but then this does not call the appropriate exit function since ofSimpleApp has it’s own function named exit() (no variable either so it doesn’t even compile)…

on the unix systems, you can just use std::exit to disambiguate the call, but how can you do this on win32? or is there a nicer way to do this?

Thanks!

so even if i remove the ofSimpleApp exit() and remove the ambiguity, calling exit(0) from inside the testApp does not actually exit!? though, this is how the callback for the keyboard exits (right?).

this is more difficult than i thought. anyone have any ideas?

so when closing the application window (the win32 window), glutGetWindow() still returns 1 and is why the exit function never gets called. hmm… why doesn’t glutGetWindow() return 0 when i close the window?

Hi pkmital,

There’s a thread about this here too.

http://www.openframeworks.cc/forum/view-…-sc&start=0

I couldn’t get the code suggested to work though and right now have had to resort to greying out the ‘x’ button so people can’t press it so that the application doesn’t hang on exit.

It’s apparently a known issue in glut as it’s mentioned in the FAQ: http://www.opengl.org/resources/faq/technical/glut.htm

Hopefully you can figure out a better solution. If so, please let us know.