LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle an exit from a custom dialog box?

Solved!
Go to solution

Hi,

 

I'm making a data acquisition program which first prompts the user to select their desired cDAQ chassis, via a custom dialog box. I created this dialog box by following the tutorial here: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000x2BiCAI&l=en-US

 

My custom dialog box functions the way I want, in that the user can select their cDAQ chassis, press "OK", and continue with the program. Or, the user may press "Cancel" and the program is aborted. However, I've noticed that when the user selects the actual "Close Window" button in the top right corner of the window, the program simply freezes. By highlighting execution on the Main VI, you can see that the program is still hung up on the custom dialog box Sub VI, which was just closed. There doesn't seem to be any way out of this besides clicking the "Abort" button on the Main VI. The issue can be replicated from the attached example files, which are the files given in the tutorial linked above.

tdav260_0-1693413758277.png

 

Is there a way to handle the "Close Window" event in a way that doesn't freeze the program? For example, I believe LabVIEW's built-in dialog boxes (such as the Two-Button Dialog) are made so that the "Close Window" button performs the same function as the "Cancel" button. Is there a way to do that with a custom dialog box?

 

Thank you!

0 Kudos
Message 1 of 5
(830 Views)
Solution
Accepted by tdav260

You have to filter the "close panel" event:

billko_0-1693417294711.png

The you can throw out that event and make a true Boolean and hook it to the loop terminator.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 5
(817 Views)

Oftentimes with a dialog I will disable the [x] button to force the user to make a choice.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 5
(809 Views)

@billko wrote:

Oftentimes with a dialog I will disable the [x] button to force the user to make a choice.


For dialogs, I will treat the "Panel Close" event as a "Cancel" and react accordingly, including possibly throwing an error.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 5
(785 Views)

@crossrulz wrote:

@billko wrote:

Oftentimes with a dialog I will disable the [x] button to force the user to make a choice.


For dialogs, I will treat the "Panel Close" event as a "Cancel" and react accordingly, including possibly throwing an error.


That is a good way as well..

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 5
(780 Views)