LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does my modal dialog window not close?

Solved!
Go to solution

I'm having trouble with a modal dialog box.

 

Here is the problem: When I click the OK or CANCEL system buttons on my dialog box, they simple toggle their pressed or unpressed appearance, but do not terminate the dialog.

 

I'm not sure how to post an image of the code for the dialog because the entire block diagram does not fit on the screen. Below is the test VI I made to call the dialog box and test it's input and output functionality, and at the end of this message is probably the most relevant part of the dialog box VI:

Main program.JPG

The dialog VI accepts a cluster as an input. In the actual dialog VI, there is the input control wired through a tunnel to the first frame of a three frame sequence structure. The first frame contains property nodes where I write the values from the input cluster into them. The second frame has a while loop, and inside the while look is an event structure.

 

The timeout condition of the event structure has a 100 ms wait, and my OK and CANCEL buttons (system buttons), wired through a tunnel to the while loops stop if true terminal. A couple other frames handle some value change events and these work fine. The third frame simply reads all my controls value properties, bundles them up, and outputs them through a tunnel out of the sequence frame and to a cluster indicator to return the result back to the calling VI. I realize that in the code as yet there is no difference between OK and CANCEL... That is coming!

 

Thanks!

 

dialog.jpg

 

0 Kudos
Message 1 of 7
(3,988 Views)
Solution
Accepted by topic author Xooch

@Xooch wrote:

The timeout condition of the event structure has a 100 ms wait, and my OK and CANCEL buttons (system buttons), wired through a tunnel to the while loops stop if true terminal.



You have nothing wired to the timeout terminal of the event structure (upper left corner), meaning it will wait forever and will never timeout. Change the event to "value changed" of the two buttons. You don't need a wait inside the event case.

 

(It is typically much better to attach code instead of images. Overall, the program seems to suffer from property node overload. Are they all really needed???)

 

Also, your teplevel code is very convoluted. The inner loop is consuming 100% of the CPU doing basically nothing, then you have an infinite outer loop using abort in the inner loop to stop the VI. There has to be a better way. Try to find it! 😄

Message 2 of 7
(3,986 Views)

@altenbach wrote:

You have nothing wired to the timeout terminal of the event structure (upper left corner), meaning it will wait forever and will never timeout. Change the event to "value changed" of the two buttons. You don't need a wait inside the event case.

 

(It is typically much better to attach code instead of images. Overall, the program seems to suffer from property node overload. Are they all really needed???)

 

Also, your teplevel code is very convoluted. The inner loop is consuming 100% of the CPU doing basically nothing, then you have an infinite outer loop using abort in the inner loop to stop the VI. There has to be a better way. Try to find it! 😄



Thank you for pointing out the timeout terminal. To be honest, this is the very first time I've tried to implement that particular part of the event structure.

 

As for the property node overload - I would be willing to hear any suggestions. I have 3 strings and 14 doubles that I'm passing into my dialog, so I need to initialize 17 controls with their starting values and read 17 control values to package them back up for a return value. I pass them to the dialog box VI as a cluster to keep the input/output terminals of the sub VIs I pass them to less complicated looking from the calling VIs.

 

I haven't found the asnwer to another question yet, but I would love to be able to define and name my own types. The cluster I use here (and other places in my program) I would create a type definition for it and name it... Currently I have a VI which is nothing but a cluster constant with a single output terminal I can drop temporarily in a VI, creeate a control or an indicator with it, then delete it.

 

And I know the top level code isn't very elegant either, it was just thrown together to test the dialog out.

 

Thanks for your reply!

0 Kudos
Message 3 of 7
(3,963 Views)

@Xooch wrote:
As for the property node overload - I would be willing to hear any suggestions. I have 3 strings and 14 doubles that I'm passing into my dialog, so I need to initialize 17 controls with their starting values and read 17 control values to package them back up for a return value. I pass them to the dialog box VI as a cluster to keep the input/output terminals of the sub VIs I pass them to less complicated looking from the calling VIs.

Well, you could keep the front panel as a single cluster control containing all the controls, this way you could initialize it with a single local variable when called and wire to the output cluster directly. Even if you keep individual controls, You would wire from the controls to the bundle node. Property nodes are ugly and inefficient. That detour is not needed.

 

In any case, I assume that the input and output cluster is the same, thus you could simply wire the input cluster to the top terminal of "bundle by name".

 


@Xooch wrote:
I haven't found the asnwer to another question yet, but I would love to be able to define and name my own types. The cluster I use here (and other places in my program) I would create a type definition for it and name it... Currently I have a VI which is nothing but a cluster constant with a single output terminal I can drop temporarily in a VI, creeate a control or an indicator with it, then delete it.


Yes, you would create your cluster once, the use the control editor and save it as a type definition (While you already use that terminology, I don't think you have done it yet). In addition of placing it as a control, you can also place it as a diagram constant.

 

 

 

 

Message 4 of 7
(3,953 Views)

@altenbach wrote:

Yes, you would create your cluster once, the use the control editor and save it as a type definition (While you already use that terminology, I don't think you have done it yet). In addition of placing it as a control, you can also place it as a diagram constant.



I use that terminology because I've done that in other text based programming languages. Getting used to drawing my code is taking some getting used to!

 

Thanks for your help.

0 Kudos
Message 5 of 7
(3,948 Views)

@altenbach wrote:

Yes, you would create your cluster once, the use the control editor and save it as a type definition (While you already use that terminology, I don't think you have done it yet). In addition of placing it as a control, you can also place it as a diagram constant.


Well, I should have looked this up way before now - My VI that spanned more than a screen now fits in less than a quarter of it.

 

Hooray for typedefs!

 

0 Kudos
Message 6 of 7
(3,920 Views)

@altenbach wrote:

Yes, you would create your cluster once, the use the control editor and save it as a type definition (While you already use that terminology, I don't think you have done it yet). In addition of placing it as a control, you can also place it as a diagram constant.


Well, I should have looked this up way before now - My VI that spanned more than a screen now fits in less than a quarter of it.


Hooray for typedefs!


0 Kudos
Message 7 of 7
(3,919 Views)