Jump to content

Application Close behaviour modification


Recommended Posts

I have a GUI with an exit button which generates a value change event to close the application by doing a number of actions including a 1 second delay to allow other loops to end. I realized that the application close icon should also provide the same actions, so I added the application close event to the event handler for the exit button and then discovered that the application does not handle the application close event the same way as the exit button event! It seems that I need to modify the application close behaviour, but cannot see how this is to be done. A hint would really be appreciated.

Link to comment

I have a GUI with an exit button which generates a value change event to close the application by doing a number of actions including a 1 second delay to allow other loops to end. I realized that the application close icon should also provide the same actions, so I added the application close event to the event handler for the exit button and then discovered that the application does not handle the application close event the same way as the exit button event! It seems that I need to modify the application close behaviour, but cannot see how this is to be done. A hint would really be appreciated.

When you close your application, you can use the "Panel Close?" event to ascertain the conditions of closing and decide what are the actions you need to do before closing. When using "Panel Close?", you'll notice that you can choose to discard the event on the right side of your event case. If you choose to discard it, the "Panel Close" event will be filtered out. By doing so, you will handle all the cases required to close your app the way you want and decide which case will effectively stop your loop(s).

Or do you really need the Application Close event?

Link to comment

I have a GUI with an exit button which generates a value change event to close the application by doing a number of actions including a 1 second delay to allow other loops to end. I realized that the application close icon should also provide the same actions, so I added the application close event to the event handler for the exit button and then discovered that the application does not handle the application close event the same way as the exit button event! It seems that I need to modify the application close behaviour, but cannot see how this is to be done. A hint would really be appreciated.

By Application Close icon, I assume you mean closing the top level VI with the red X in the top right corner of the active window. If so, don't use the Application Close event - instead, use the <this vi=""> Panel Close? event and set the Discard? property to True (the property shows up on the event case after you select this event). What this does is catch the panel close event and filters the actual panel close command. So the panel will not close but you can use the event to fire whatever's in the event case that handles it (could be the same code as your exit button calls) and then use a property node to close your panel after all your clean-up code executes. The only complication to this approach is that the Panel Close? and Value Change? events can't have the same event handling case so you might want to have your cleanup code in a SubVI to make it easy to call from two places. Or another approach (some might consider it a hack but I think it's OK in this particular situation) is to just have the Panel Close? case fire the Exit button's value signaling property to force the Exit case to execute.

Mark<br><br>Edit: OK, Francois types faster than I do :)<br></this>

Link to comment

One thing to add to the Panel close? event is that you should hide the front panel in that event case, that's because the user will be irritated because the front panel won't close and will click it multiple times.

So handle the Panel Close? event, set your FP style to hidden and then start closing you app. when done activate a panel.close method.

Ton

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.