LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

threads, tabs and duplicate controls 2

Thanks for replying so quickly. As requested I have attached the files and the error message that I get, when I try to use any of the duplicated controls. The message is" fatal runtime error. simpdemo.c line 33 col 5, thread id 0x00000155, The program has generated a General Protection error at 001B02281348".

Hope this helps. I did exactly the same in a more complex application and get the same error when trying to use a duplcated control on a tab panel.

Regards

Erik Wegman
email ewegman@csir.co.za
Download All
0 Kudos
Message 1 of 2
(2,861 Views)
Erik,
the problem lies in that the EasyTab instrument chains its own callback to the callback of all the controls in the panels. If you call your Init() function AFTER having loaded the panels in the EasyTab control, the chain of callbacks is broken, and somewhere in the instrument you get this type of error.

The solution is simple:
1. Load the panels
2. Duplicate controls (implicitly adding callbacks to them)
3. Add panels to the EasyTab control

I modified your code this way and now it runs:

//EasyTab_LoadPanels (panel, tabCtrl, 1, "simpdemo.uir", __CVIUserHInst, CONTROL, &panelArray[0],
// VALVES, &panelArray[1], MONITOR, &panelArray[2], CONFIG, &panelArray[3], HELP, &panelArray[4], 0);
panelArray[0] = LoadPanel(panel, "simpdemo
.uir", CONTROL);
panelArray[1] = LoadPanel(panel, "simpdemo.uir", VALVES);
panelArray[2] = LoadPanel(panel, "simpdemo.uir", MONITOR);
panelArray[3] = LoadPanel(panel, "simpdemo.uir", CONFIG);
panelArray[4] = LoadPanel(panel, "simpdemo.uir", HELP);
Init();
EasyTab_AddPanels (panel, tabCtrl, 1, panelArray[0], panelArray[1], panelArray[2],
panelArray[3], panelArray[4], 0);

This is problably the same problem you hava in the other project you are working to.

One more little hint: I moved the declarations of panel and tabCtrl into the main() function. As per panel variable, since 'panel' is the default name of an argument of all control callbacks, I tend to avoid problems that arise in having a global and a local variable of the same name (besides all, you don't need a global variable for the main panel handle, since it is passed to all control's callbacks). A global tabCtrl variable is not necessary for the project to work, so I moved into main() fu
nction too (unless I do need variables to be global, I personally prefere to have them local to functions in which are used).

Hope this helps
Roberto


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 2
(2,861 Views)