10-02-2017 06:31 AM
I receive a weird error in a program of mine where I want to call ChainCtrlCallback on controls tha reside on a tab page.
When I try to LoadPanel the panel with the tab control inside, I receive error -86, that is:
NON-FATAL RUN-TIME ERROR: The callback function, xxxx, specified in the UIR file, does not have the required prototype.
I know this is non-fatal, but nevertheless it prevents my program from executing correctly.
I know there was a similar situation with the old EasyTab control, which has been superseded by native Tab Control (e.g. see here) but the proposed solution for the EasyTab (customize the panel before loading it to EasyTab) cannot easily work with Tab controls.
All messages and documents on ChainCtrlCallback refer to the EasyTab control, I didn't find any on native tab controls: has anybody found the same error ? And how did you solve it?
10-02-2017 01:30 PM
Could you provide a small example of what you're doing?
I'm curious how you're calling ChainCtrlCallback without pre-loading the parent panel of the tab. You need the panelHandle of the tab to call ChainCtrlCallback, which i'm not sure how to get besides calling GetPanelHandleFromTabPage and passing in the parent handle.
-Trent
10-03-2017 01:59 AM - edited 10-03-2017 02:07 AM
You're right, I need the tab page handle to manipulate controls. The error is raised exactly when loading that panel (LoadPanel instruction), and only if I am chaining functions to controls in a tab page; if I chain the same function to controls on the parent panel no error is raised and the code works as expected.
tmpH = LoadPanel (0, UIR, SettingsPnl); if (tmpH < 0) goto Error; // Error while loading panel // Manipulate controls on the panel // I can ChainCtrlCallback to controls on the panel // Page 2 of the tab control GetPanelHandleFromTabPage (tmpH, SettingsPnl_TAB, 2, &pnlH); ChainCtrlCallback (pnlH, ctlP_new, ModiParm, (void *)SettingsPnl_save, "modiParm"); ... ... // Definition of ModiParm function int CVICALLBACK ModiParm (int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
To mimic the sistuation of the old EasyTab control, I should load the panels as standalone instances, customize them with ChainCtrlCallback and then use InsertPanelAsTabPage to insert them in the tab control. I haven't tested so I don't know if it will work: it looks weird and inconvenient and I hope that an alternative exists!
10-03-2017 05:45 AM
Well, I was developing a simple example that shows this behaviour but I have found that all works as expected there, including ChainCtrlCallback!
I have to invesitigate a bit more on what's happening: my project as you may understand is way more complex that this example, in particular the chained callback is enclosed in a tool library of my own; maybe this has an influence on that, I don't know.
I am attaching the sample project just to understand what I am trying to do.
10-03-2017 08:22 AM - edited 10-03-2017 08:26 AM
Hmmm, no luck!
I moved the chained function to a separate library but still all works well. I don't understand why the same process in my app gives that wrong-function-prototype error.
And misteriously, if I move in the final app the code from the library to a local function, all works well again!
10-03-2017 09:28 AM - edited 10-03-2017 09:34 AM
This is strange indeed, maybe it's related to include/compile order? If the library is compiled separately, and doesn't actually use that prototype anywhere, maybe it's getting optimized out. Turning off optimizations in the Build Options would be an easy way to test that.
Edit: Actually, that theory doesn't make any sense in reference to the text of the error:
NON-FATAL RUN-TIME ERROR: The callback function, xxxx, specified in the UIR file, does not have the required prototype.
It obviously knows where it is defined, but there's something slightly different about the prototype?
10-03-2017 10:36 AM
Trent, after making some tests more, it seems the problem is using the offending function in ChainCtrlCallback calls, there is no relation to tab pages. I tried chaining the function to controls on the parent panel and got the same error.
If otherwise the same function is used as a control callback, regardless controls are on tab pages or not, I never get any error.
I have been using this library function as a control callback from several years now, but I never tried chaining it; the fact is, I am now developing an application with a slightly more complicated UI where that chaining could simplify a little events handling.
10-03-2017 10:57 AM
Going a little bit further, I tried adding my complete library to the test project instead of the smallest abstract and things works like a charm
I see no major differences between the project structures: the complete application includes the excel instrument but it makes no difference: even stripping it out the error arises as well.
The only difference between the UIR include file and the library one is that the definition in the library file is splitted in two lines, but readjusting it to single line makes no difference.
I am very puzzled by this strange behaviour but unfortunately I have very strict timing so I suppose I will work it around copying the function to the project code and using the local version that exhibits no error.