# Lock or Disable the Windows Closebox

**URL:** <https://forum.servoy.com/t/lock-or-disable-the-windows-closebox/485>\
**Category:** Classic Servoy\
**Created:** [October 25, 2003, 11:07am UTC](https://forum.servoy.com/t/lock-or-disable-the-windows-closebox/485 "2003-10-25T11:07:01Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![agis](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@agis](https://forum.servoy.com/u/agis)\
**Post date:** [October 25, 2003, 11:07am UTC](https://forum.servoy.com/t/lock-or-disable-the-windows-closebox/485/1 "2003-10-25T11:07:01Z")

</div>

Clicking in the closebox of the window of a Solution of Servoy will not only close the solution but also shut down the programm. I would like to avoid both.  
With starting a transaction you should be able to avoid undesired canceling of a script. Clicking the closebox will show a dialog which asks for commiting the running transaction: clicking Yes will save changes, but clicking No will also save changes, in every case servoy will be shut down.  
Is there a way to catch all attempts of closing a window and handling this?

(In filemaker with the comand: Allow User Abort it is possible to prohibit closing a Window at runtime.)

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [October 29, 2003, 11:53am UTC](https://forum.servoy.com/t/lock-or-disable-the-windows-closebox/485/2 "2003-10-29T11:53:01Z")

</div>

Servoy release 1.2 rc6 supports solution onOpen/onClose properties in the preferences, onClose will always be called before the window closes.

---

<div class="post-metadata">

**Author:** ![agis](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@agis](https://forum.servoy.com/u/agis)\
**Post date:** [November 1, 2003, 1:32pm UTC](https://forum.servoy.com/t/lock-or-disable-the-windows-closebox/485/3 "2003-11-01T13:32:20Z")

</div>

Thank you for this advise!  
We’ve found the new menu-item called solution-settings in tools for choosing a startUp and closing method out of the existing global methods. In the closing-script we can rollback transaction or even ask for committing transaction by dialog.  
But is there a way to stop the unwished closing of the solution in the closing method also?  
Is there any command which could stop closing when the closing method is executed in a before phase or would disabeling the closebox of the window be the solution?

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [November 2, 2003, 11:45am UTC](https://forum.servoy.com/t/lock-or-disable-the-windows-closebox/485/4 "2003-11-02T11:45:02Z")

</div>

Also see [http://forum.servoy.com/viewtopic.php?t=619](http://forum.servoy.com/viewtopic.php?t=619)

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [November 2, 2003, 12:07pm UTC](https://forum.servoy.com/t/lock-or-disable-the-windows-closebox/485/5 "2003-11-02T12:07:13Z")

</div>

yes, it would be nice, that you can prevent users from closing the app.

something like this:

```auto
dialogResult = plugins.dialogs.showDialog('Alert','Do you want to Quit?','Yes','Cancel');	
if ( dialogResult == "Yes" )
{
	application.exit
}	
else
{
	return; //do not quit!
}

```

This is not working now!

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [November 25, 2004, 1:08pm UTC](https://forum.servoy.com/t/lock-or-disable-the-windows-closebox/485/6 "2004-11-25T13:08:01Z")

</div>

I know I have seen this working in somebody’s solution (asking a user if he wants to close or not)… Does anybody know how to do this?  
Thanks!  
Patrick

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [November 25, 2004, 2:28pm UTC](https://forum.servoy.com/t/lock-or-disable-the-windows-closebox/485/7 "2004-11-25T14:28:04Z")

</div>

I think it’s attaching an onclose method to your solution (solution Settings)

If you let the method return a “false”, then the solution is not closed.

Paul

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [November 25, 2004, 2:29pm UTC](https://forum.servoy.com/t/lock-or-disable-the-windows-closebox/485/8 "2004-11-25T14:29:23Z")

</div>

That is what I am trying ![:wink:]( "Wink"), but it closes anyway…

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [November 25, 2004, 5:00pm UTC](https://forum.servoy.com/t/lock-or-disable-the-windows-closebox/485/9 "2004-11-25T17:00:33Z")

</div>

just tested this. with a simple solution close method (return globals.close == 1) in that method.

Works fine. I can’t close the solution or servoy when the globals.close is not 1.

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [November 25, 2004, 5:03pm UTC](https://forum.servoy.com/t/lock-or-disable-the-windows-closebox/485/10 "2004-11-25T17:03:14Z")

</div>

hmm, what I tried is the code above:

dialogResult = plugins.dialogs.showDialog(‘Alert’,‘Do you want to Quit?’,‘Yes’,‘Cancel’);  
if ( dialogResult == “Yes” )  
{  
application.exit  
}  
else  
{  
return; //do not quit!  
}

That doesn’t seem to work.

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [November 25, 2004, 5:15pm UTC](https://forum.servoy.com/t/lock-or-disable-the-windows-closebox/485/11 "2004-11-25T17:15:55Z")

</div>

as also specified above. you have to return true or false!

so don’t do return; but return false;

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [November 25, 2004, 5:20pm UTC](https://forum.servoy.com/t/lock-or-disable-the-windows-closebox/485/12 "2004-11-25T17:20:22Z")

</div>

Got it! Thank you!
