# \[Solved\] Ask before closing the window

**URL:** <https://forum.juce.com/t/solved-ask-before-closing-the-window/62012>\
**Category:** General JUCE discussion\
**Created:** [June 28, 2024, 9:42am UTC](https://forum.juce.com/t/solved-ask-before-closing-the-window/62012 "2024-06-28T09:42:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcusonic](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@Marcusonic](https://forum.juce.com/u/Marcusonic)\
**Post date:** [June 28, 2024, 9:42am UTC](https://forum.juce.com/t/solved-ask-before-closing-the-window/62012/1 "2024-06-28T09:42:36Z")

</div>

I need under some circumstances notify and ask for confirmation to finish when closing the window

---

<div class="post-metadata">

**Author:** ![bencekovacs](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@bencekovacs](https://forum.juce.com/u/bencekovacs)\
**Post date:** [June 28, 2024, 11:21am UTC](https://forum.juce.com/t/solved-ask-before-closing-the-window/62012/2 "2024-06-28T11:21:12Z")

</div>

You can achieve this by overriding the `systemRequestedQuit` method to prompt for confirmation before closing.

[https://docs.juce.com/develop/classJUCEApplication.html#a8e9b08200268216a791326635ec9321c](https://docs.juce.com/develop/classJUCEApplication.html#a8e9b08200268216a791326635ec9321c)

---

<div class="post-metadata">

**Author:** ![QuilioLtd](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/quilioltd/32/15459_2.png) [@QuilioLtd](https://forum.juce.com/u/QuilioLtd)\
**Post date:** [June 29, 2024, 7:17am UTC](https://forum.juce.com/t/solved-ask-before-closing-the-window/62012/3 "2024-06-29T07:17:19Z")

</div>

Thanks. Does it open the native OS confirmation window?

---

<div class="post-metadata">

**Author:** ![bencekovacs](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@bencekovacs](https://forum.juce.com/u/bencekovacs)\
**Post date:** [June 29, 2024, 8:40am UTC](https://forum.juce.com/t/solved-ask-before-closing-the-window/62012/4 "2024-06-29T08:40:39Z")

</div>

> [@QuilioLtd](#):
>
> Does it open the native OS confirmation window?

No, but you can create the native dialog with this class inside the previously mentioned method:  
[https://docs.juce.com/master/classNativeMessageBox.html#details](https://docs.juce.com/master/classNativeMessageBox.html#details)

And here’s an example of how it can be used:

> [@Displaying OkCancel window](https://forum.juce.com/t/displaying-okcancel-window/47646/3):
>
> Thank you! I just solved this problem. For anyone who encountered the same problem, here’s the detailed solution. const auto callback = juce::ModalCallbackFunction::create ([this](int result) { if (result == 0) {}// result == 0 means you click Cancel if (result == 1) {}// result == 1 means you click OK }); juce::NativeMessageBox::showOkCancelBox(juce::AlertWindow::InfoIcon, "Title", "Message", nullptr, callback);

I hope this helps.
