LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding panels to uir causes child panel loading failure

Solved!
Go to solution

Hi!

 

I have an application which consists of a single panel with a single child panel loaded from an uir file. The panels are loaded like this:

 

if ((parentHandle = LoadPanel (0, file_name, PARENT)) < 0)
exit(EXIT_FAILURE);

if ((childHandle = LoadPanel (PARENT, file_name, CHILD)) < 0) //Fails if I add two more panels in the uir
exit(EXIT_FAILURE);

 

I wanted two more child panels, and create them in the same way as I did the first one. However, without even adding code that loads them, this causes the loading of the original child panel to fail with "Function LoadPanelAnsi: return value -42. The handle is not a panel handle."

 

If I only add one more child panel (either of them) then nothing bad happens, and the code runs happily.

 

How is it possible that the addition of a panel which is not even loaded can cause the program to fail where it previously worked fine? I have double-checked that none of the panels share names, if that could cause issues.

0 Kudos
Message 1 of 4
(1,260 Views)
Solution
Accepted by topic author guybrush_threepwood

There is a problem in your command: as you can see in the function help, to load a child panel the first parameter must be the panel handle, not the panel name.

And you receive an error (the handle is not a panel handle) which clearly speaks of panel handle



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 2 of 4
(1,238 Views)

Aha! Thank you! I did not notice that I used the wrong variable since the code worked previously. Must have gotten lucky!

0 Kudos
Message 3 of 4
(1,195 Views)

Most probably while adding the additional panels to the .UIR file you have messed up their order so that PANEL now evaluates to a value that the system cannot associate to an active panel in memory. In any case, the correct way is to use the handle returned by LoadPanel which identifies an actual instance of the panel (as you may imagine you may load the same panel more than once: you can discriminate them by the handle which is unique for each instance while the constant name is the same for all of them).



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 4 of 4
(1,190 Views)