06-18-2021 09:42 AM
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.
Solved! Go to Solution.
06-18-2021 10:22 AM - edited 06-18-2021 10:25 AM
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
06-21-2021 02:00 AM
Aha! Thank you! I did not notice that I used the wrong variable since the code worked previously. Must have gotten lucky!
06-21-2021 02:14 AM
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).