LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GetUserEvent and InstallPopup

Hi, all

 

I did some refactoring of the example, and the problem seems to be solved by making the child and grandchild panels children of their parent panels. There is a note in InstallPopup which warns that 'unexpected behavior' might result from using child panels as modal dialogs, and this appears to be because InstallPopup temporarily promotes child panels to the level of parent panels until RemovePopup is called. During that interval in which the child popup is no longer a child, if you try to use child-panel specific features for the popup, unexpected things can happen.

 

Please see the attached project.

 

Thanks,

Daniel Dorroh
National Instruments
Message 11 of 18
(1,597 Views)

That is EXCELLENT!!!!!!!! thank you 🙂

Is this documented anywhere? or was it found by accident?

Either way I appreciate your concern and the fix.

0 Kudos
Message 12 of 18
(1,582 Views)

I must admit that I don't understand the problem: can somebody explain me? Smiley Frustrated

 

Let's look at the original project supplied by PopUpProblem:

When I press "Create a child" the popup is created and no action can be taken in the original panel: ok, that's what popup panels are for.

When I press "Create a grandchild" the panel is created and no action can be taken on the first two panels. That should be good again.

When I dismiss the grandchild I can still operate on the child and when I dismiss this last one I can operate on the parent panel.

 

The modification by dcubed works the same way.

 

What am I missing?? 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 13 of 18
(1,553 Views)

Hi Roberto,

 

The problem, as I understand it, is that the GetUserEvent does not react to EVENT_COMMIT events from clicking the grandchild window's 'Done' button until EVENT_COMMIT events are raised by the child window's 'Done' button. You can see the difference in behavior by changing the following code from:

 

if ((_fatherPanel = LoadPanel( 0, "FatherUir.uir", PANEL )) < 0)
return -1;
if ((_childPanel = LoadPanel( _fatherPanel, "ChildUir.uir", CHILD )) < 0)
return -1;
if ((_grandchildPanel = LoadPanel( _childPanel, "ChildUir.uir", GRANDCHILD )) < 0)
return -1;

 

to 

 

if ((_fatherPanel = LoadPanel( 0, "FatherUir.uir", PANEL )) < 0)
return -1;
if ((_childPanel = LoadPanel( 0, "ChildUir.uir", CHILD )) < 0)
return -1;
if ((_grandchildPanel = LoadPanel( 0, "ChildUir.uir", GRANDCHILD )) < 0)
return -1;

  

in my attached code.

Daniel Dorroh
National Instruments
0 Kudos
Message 14 of 18
(1,547 Views)

Ok, I didn't focused on the buttons having a callback themselves.

I see what you are saying, but I consider using control callbacks AND GetUserEvents together a risky way and frankly it seems a bad programming habit to me.

I cannot even figure a reason to handle the very same commit event two times in different moments in program life.

 

When I use popup+GetUserEvents I set no callbacks on buttons and handle all commit events inside a loop on GetUserEvents; alternatively, I set controls as 'normal' and trap click or value change or other events inside the control callback. This way I am guaranteed that events are processed by one manager only. I do not want to run the risk that under unpredicted conditions events are handled in a different order by concurrent managers.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 15 of 18
(1,539 Views)

I have 2 questions for D_Cubed regarding your example code.

1- What is the meaning of the underscore preceding all the user defined variables?

2- Why the RemovePopup instead of the HidePanel? By doing a HidePanel I believe I can repaint it without reloading it, where as by Removing it I believe I have to do a re-load.

0 Kudos
Message 16 of 18
(1,504 Views)

Hi PopUpProblem,

 

  1. In the example, I use an underscore prefix to indicate a global variable. Sometimes you see people use g_ or some other prefix, but I prefer a simple _. You'll notice that it is not all user-defined variables that follow this convention; locally-scoped variables in the example do not have a prefix (e.g., whichPanel).
  2. I use RemovePopup, because it is the correct function to use when removing pop-up panels. For more information on using LabWindows/CVI pop-up panels, see programming with pop-up panels in the help. You do not need to re-load a panel after calling RemovePopup.

 

I hope that helps!

Daniel Dorroh
National Instruments
0 Kudos
Message 17 of 18
(1,476 Views)

Thanks for the clarifications 🙂

0 Kudos
Message 18 of 18
(1,459 Views)