Custom Window: detect if user click the close button

Post your suggestions for future versions of NeoBook

Moderator: Neosoft Support

Locked
User avatar
Cipolla
Posts: 166
Joined: Fri Apr 01, 2005 1:45 am
Location: Germany
Contact:

Custom Window: detect if user click the close button

Post by Cipolla »

I need to fire some actions before a user clicks the close button (the red X at the title bar) of a custom window. Just like the shutdown action. I want to pop up a message box,
asking the user if he really want´s to close the CustomWindow. If not, i want the CustomWindow to stay open.

Any Idea, or suggestion for another update?
Greetings from Germany
Klaus
User avatar
HPW
Posts: 2571
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany
Contact:

Re: Custom Window: detect if user click the close button

Post by HPW »

You may use the NoCloseBtn option for the customwindow and provide your own close-button where you can code what you want.
Hans-Peter
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: Custom Window: detect if user click the close button

Post by Gaev »

Klaus:
I want to pop up a message box,
asking the user if he really want´s to close the CustomWindow. If not, i want the CustomWindow to stay open.
Not sure if you can prevent the Custom Window from closing ... but (from the Help file) ...
You can define special subroutines that will be executed when a specific custom window is opened or closed. To do this, simply create two subroutines - one called ObjectName_OnOpen and one called ObjectName_OnClose. Replace ObjectName with the name of object used when opening the window. For example, the subroutines for our Container1 sample above might look like this:

:Container1_OnOpen
AlertBox "Hello" "The window is opening."
Return
:Container1_OnClose
AlertBox "Hello" "The window is closing."
Return
Would be nice if there was a way to tell NeoBook (in the :Container1_OnClose subroutine) to "Cancel/Ignore the User Request"

Another option would be to use the NoCloseBtn "options" parameter of the CustomWindow command.

Also, you could try using the NoBorder option ... and then simulate title bar and the X with other objects.
User avatar
Cipolla
Posts: 166
Joined: Fri Apr 01, 2005 1:45 am
Location: Germany
Contact:

Re: Custom Window: detect if user click the close button

Post by Cipolla »

HPW wrote:You may use the NoCloseBtn option for the customwindow and provide your own close-button where you can code what you want.
Thanks for your reply.

Yup. i have a Save & Cancel Button on stage, but for the look and feel, the customers wants a "real" windows like red 'X' ;-)
Not sure if you can prevent the Custom Window from closing...
I thought about that, but the subroutine is fired AFTER the window is closed. :-(
Also, you could try using the NoBorder option ... and then simulate title bar and the X with other objects.
Not really an option, because on different systems the windows title bar looks always different.

So it seems there is no native solution.

Dave, is it possible to implement this kind of behaviour?
Greetings from Germany
Klaus
User avatar
Wrangler
Posts: 1531
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA
Contact:

Re: Custom Window: detect if user click the close button

Post by Wrangler »

but for the look and feel, the customers wants a "real" windows like red 'X'
This can be done by taking a snapshot of a regular windows window title bar and red 'X'. Then you can superimpose a transparent button over the x and a text box with variable for the title. If done correctly, you can't tell the difference.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: Custom Window: detect if user click the close button

Post by Gaev »

Wrangler:
This can be done by taking a snapshot of a regular windows window title bar and red 'X'. Then you can superimpose a transparent button over the x and a text box with variable for the title. If done correctly, you can't tell the difference.
Will not work if the "windows style" used by his clients is different from the "style on the Developers machine where the image was snapped"
User avatar
Wrangler
Posts: 1531
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA
Contact:

Re: Custom Window: detect if user click the close button

Post by Wrangler »

Well, then it's a matter of how important that is? How upset could one get that the theme doesn't match their installed theme perfectly? If you used the default windows theme, the odds are you would cover most users anyway.
like red 'X'
I think these are the keywords here. What I propose would fullfill that request.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
Neosoft Support
NeoSoft Team
Posts: 5628
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA
Contact:

Re: Custom Window: detect if user click the close button

Post by Neosoft Support »

Would be nice if there was a way to tell NeoBook (in the :Container1_OnClose subroutine) to "Cancel/Ignore the User Request"
I will add this to the list of things to consider for the future.

However, the way I would handle this would be to simply hide the close button like the custom window's NoCloseBtn option does. Then give the user a clear option like an OK, Accept or Done button to click when they have completed the necessary steps. The windows "X" button is supposed to mean the same as the "Cancel" button. When collecting input from the user is critical, then there should be no close or cancel options - only OK, Accept, etc.

From Microsoft's Windows Style Guide:
The Close button on the title bar should have the same effect as the Cancel or Close button within the dialog box. Never give it the same effect as OK.
NeoSoft Support
User avatar
Cipolla
Posts: 166
Joined: Fri Apr 01, 2005 1:45 am
Location: Germany
Contact:

Re: Custom Window: detect if user click the close button

Post by Cipolla »

Dave, thank you for putting this on your to do list :)
Greetings from Germany
Klaus
User avatar
Garic
Posts: 107
Joined: Wed Sep 26, 2012 8:42 am

Re: Custom Window: detect if user click the close button

Post by Garic »

This feature is implemented in the plugin ksOnMoveSizeCustWin
Using variables [ShutdownSourceCustWin] and [ShutdownStatusCustWin], you can intercept the close button of the custom window.
Look at an example that comes with the plugin.
ks
.............
Image
Locked