From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Identifying selected tabs within tab control

I'm looking for a way to determine which tab is selected within the CVI tab control. The index is available, but the index isn't that helpful if the tabs aren't always in the same order. The Constant Name is used to identify controls on the tab page, but it doesn't look like there is a function to find the actual tab ID.
 
I was thinking that a work-around is to programmatically add the panels to the tab control and track the IDs against the index in a table.
 
The header file that is generated from the UIR only refers to the Constant Name as part of the #define associated with the controls.
 
Any ideas ?
0 Kudos
Message 1 of 4
(3,477 Views)
Notice that there is a function called GetTabPageAttribute that will return specific properties about a certain tab page using the index, one of which being the label text.  In fact, there are several unique tab functions that you might be interested in.  You can find them in the Library Tree in the bottom left corner of CVI under User Interface Library>>Controls/Graphs/Strip Charts>>Tabs.
 
Hope this helps!
Thanks,

Andy McRorie
NI R&D
0 Kudos
Message 2 of 4
(3,447 Views)

It's true that you can use the label text and discover the active panel by means of a series of comparisons between strings, but it seems to me not the best way to go and surely not the fastest. The same consideration applies to ATTR_CONSTANT_NAME (the panel attributes which returns the text of the constant name, e.g. "MyPanel"). Moreover, this last solution leads to these additional critical points

1. If you load a panel more than once, this approach doesn't give you a unique solution

2. On the other side, supposing you can retrieve the value associated to the constant name, this value is unique only if all tab panel are defined in the same UIR file, otherwise their IDs could overlap

In my opinion your solution of programmatically load panels and save panel handles in a array is the only possible way to go, since only panel handles are unique throughout the whole application.

BTW, in the header file associated with the UIR panel constant names are listed too: in every group of #defines that refer to a panel and its controls, the very first is the panel constant name with its associated value (used in LoadPanel).

Message Edited by Roberto Bozzolo on 01-05-2007 12:15 AM



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 3 of 4
(3,446 Views)

To your point, there is a way to look up the index of a selected tab page with a call to GetCtrlIndex.  Works well.

 

For myself, I have been searching for a way to find the index of a tab page before selecting it for a while now.  Like a nice rational definition of pi, it just dont' exist!

 

Your thought of programmatically adding a panel to a tab control is likely the only way to go, if you are trying to define tab page panel handles before they are selected.

0 Kudos
Message 4 of 4
(2,887 Views)