How do I disable the X (close) button on the window


I have seen some programs that have disabled the X button (on Windows). I was wondering if there was a way to do this in oF.

Another solution would be being able to catch the window close action produced by clicking the X. Is this possible in oF?


This link might help. Provided that you’re using GLFW as your windowing system.

this still works ? will it work crossplatform ?


You can also try the decorated=False parameter when you do the window setup. The X will not be there, but you cannot move the window easily without writing it manually in mouseDragged()

Nope, I need the X button and show a “Do you want to save before leaving” message. Thanks

You could add to ofApp.h:

void exit();

And to ofApp.cpp

void ofApp::exit(){
  //this will get called right before the app closes. 
  //add your pop up dialog here
1 Like

I remember using glfwWindowCallback functionaity.
I used that to disable closing the app, when the X button was pressed. You can see how its done in the glfw docs:

I did those because I did not found a way to stop the closing process inside ofApp:exit(). Maybe there is and I’m not aware of that…

For you use case maybe it’s not the best solution, but maybe someone finds it useful searching for this topic.