LabWindows/CVI Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Peter Cooper

CVI Function: GetPanelHandleFromTabPage has limitations

I added the tab control into panel to my project. Overtime, I added 20 items into the single Tab Control. But since were so many items in the tab control, I decided to re-arrange items (indexes) in the tab control by either moving them left or right depending on the alphabetical order. But here is my problem.

 

Since I re-arranged the items (indexes), the indexes have all changed for all the items. Now I have to go everywhere the function GetPanelHandleFromTabPage is called and manually update the index numbers to match panel handles for the index. There are 20 different places where this could occur. The number of items (indexes) on the tab control could grow even more and may have to be re-arranged again in the future. Just a big pain.

 

Suggestion for improvement: Provide a another function that can obtain the index of the item on the tab control dynamically. This could be done by using the "Constant name:" issued in the edit tab panel of the edit tab control. So if the items (index) inside the tab control are re-arranged then the index value for that item is carried with the new index value.

 

Also the index would be included in the header file generated by the panel editor for CVI so that now the index value can be used thus eliminating the hard coded the index value.

3 Comments
LuisG
NI Employee (retired)
Status changed to: Under Consideration
 
john_cvi_user
Member

I agree that this would be a useful function in the uir header file.

 

But until NI do this try:

defining the page numbers as constant integers in a seperate .h file,

using #define page1   0 (pages are 0 indexed)

 

Declare a page handle for each page as a global (in the same .h file) integer.

 

Then have one function to load all the tab handles using GetPanelFromTabPage which is called near the top of the main function.

 

If you need to change your gui its then easier to change your .h file to re-order the pages and then make sure you have the correct GetPanelFromTabPages for each page.

Using this it is also easy to nest tab pages.

 

Hop this helps

 

 

gdargaud
Active Participant

I also thought that having a const with the name of the tab was necessary and an oversight by NI, but I just thought of a problem.

Say you have a tab control TAB on panel PNL. This control tab has 3 tabs: TA, TB and TC.The constants on them are named T0_NUMERIC_1, etc...

Now assume that we now have #define T0 0, etc in the uir file so that we can call GetPanelHandleFromTabPage (panel, PNL_TAB, TC, &pTC)

If we remove TB: DeleteTabPage (panel, PNL_TAB, TB, 1), then the above line is no longer valid.

 

I see this as a problem for instance in an init process where you read a tab initial config from a file and hide, dim or delete some tabs as you go, then all your constants are now wrong.

 

Solution: There needs a way to discriminate tabs not based on their index (which can change) and not based on their name (which can be identical).