11-18-2010 02:38 AM
Hi,
I am aware that the very same question has been asked more than three years ago - but I still can't find the problem in what I am doing...
Description: On a panel, I have two tab controls, tab A with three tab controls and tab B with two. For the following discussion, tab B is of no interest. Each tab control has several numeric indicators, both of type integer and double. Now I want to add a fourth tab control to tab A. This works.
In the next and problematic step, in the UIR editor I select the new tab (the right most) and move it two positions to the left. Still it is ok until I try to display some numeric value on tab control 3 (the new tab control is left to it). I receive an error in the calls to SetCtrlAttribute, complaining about an invalid control ID... However, I did not touch any control on the tabs, nor add any new control. Also, I did not touch the generated include file... Visual inspection did not show any change in the include file (the new tab control is listed only once some controls are added to it)
Displaying numbers on the first/leftmost control tab works, only on tab 3 and 4 that are right to the new (and still empty) new tab generate this error. Adding a control to the new tab does not change the bahavior.
Help is appreciated!
Wolfgang
Solved! Go to Solution.
11-18-2010 01:55 PM
Wolfgang,
When you get the handle for your tab using GetPanelHandleFromTabPage:
GetPanelHandleFromTabPage(MainPanelHandle, PANEL_TAB, 0, &TabHandle);
the third parameter is an index for the specific tab you want to address. If you change the order of the tabs, then you have to change the index, too. For example, let's say you have a numeric control on the third tab from the left. You want to set it to some value, so you do this:
GetPanelHandleFromTabPage(MainPanelHandle, PANEL_TAB, 2, &TabHandle);
SetCtrlVal(TabHandle, TAB_numMyNumeric, 1);
Now you add a new tab to the left of the tab with the numeric contorl. The new tab is now index 2 and the original tab is index 3. When you call:
GetPanelHandleFromTabPage(MainPanelHandle, PANEL_TAB, 2, &TabHandle);
you get the handle for the new tab. It doesn't have a control with the same ID as TAB_numMyNumeric, so you get a runtime error.
Personally I like to use an enum for my tabs so I can keep them straight:
enum { MY_FIRST_TAB, MY_SECOND_TAB, MY_THIRD_TAB, ... };
Then if I reshuffle the tabs or add a new one, I just have to re-order the enums and everything works fine. I use the same names in my tab constants, too, to help keep things straight:
GetPanelHandleFromTabPage(MainPanelHandle, PANEL_FIRST_TAB, MY_FIRST_TAB, &TabHandle);
Tony G.
11-19-2010 12:26 AM
Thanks Tony, I forgot about this assignment!