LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How change the active page of tabcontrol by program

Hi,

I'm a new user of LabWindows. Before, I'm using Delphi7.

I have a problem with the new TabControl with LabWindows.
My tabcontrol config is like this :
- Two pages
- The "tabs visible" property is not enabled
- Each page contain a button.

I will make the page switching when the user click on the button from the current page.

A property to select the current active page don't seem exist with tabcontrol.

Could you help me ?

Thanks.

Vincent
================================
Labwindows version : 8.0.1 (356)
OS : windows XP SP2


0 Kudos
Message 1 of 6
(6,077 Views)

Hello Vincent,

there are two ways to change the active tab page. The first one is using the SetActiveTabPage function. Another method is using SetCtrlAttribute with the ATTR_CTRL_INDEX attribute. There is a slight difference between these two methods. When using SetActiveTabPage, the focus will go to the activated tab, and one of the controls on this tab page will become the active control, receiving keyboard input etc. When using SetCtrlAttribute, the tab page will become visible, but the control that was active before calling the function will still be active after the function is executed.

Success,

Wim

Message 2 of 6
(6,076 Views)
Hi Wim

How are you ?
Thanks for your answer.
I still have the same problem but I don't know why.

Look the test config on the following picture.

1st config :
I manage the Click event from the OUT Button : this button is a member of the panel.
I can write the current index in the numeric box with the following code :
                    GetActiveTabPage(panel,PNL_TAB,&index);
                    SetCtrlVal(panel,PNL_NUMERIC,index);
When I click on the button, the value in the numeric box is updated

2nd config :
I manage the Click event from the IN Button : this button is a member of a page , in my tab control.
With the same code, like the first case, i can't visualize the number of the active page in the numeric box.
When I play with the debbugger, I can see that the index value is not setting by the Get ActiveTab Page function.
Instead of having  a value '1'or '2' for the index variable, there is a value 234234234.

Can you explain this mystery ?


Vincent
0 Kudos
Message 3 of 6
(6,056 Views)

Sorry Vincent, I have no idea what's causing the problem in the second configuration.

What happens if you replace the code GetActiveTabPage(panel,PNL_TAB,&index); by GetCtrlAttribute(panel,PNL_TAB,ATTR_CTRL_INDEX,&index); ?

0 Kudos
Message 4 of 6
(6,052 Views)

There is a reason for this behaviour: every time you add a page to the tab control the system is really creating a (child) panel related to that tab page; if you add a breakpoint inside your functions you will see that "panel" variable in OUT button callback has a differemt value from that of IN button callback. Given this, you can use GetActiveTabPage function from the parent panel (the panel the tab control is on) but not from the chile panel (any of the tab pages) since tha panel handle received from Out button is NOT that of the parent panel. Parent panel handle can be retrieved as a panel attribute of the tab page, this way:

 GetPanelAttribute (panel, ATTR_PANEL_PARENT, &pH);
 GetActiveTabPage (pH, PANEL_TAB, &index);
 SetCtrlVal (pH, PANEL_NUMERIC, index);

These lines are to be added to your IN button callback.



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?
Message 5 of 6
(6,025 Views)
Hi,

I've just test the Roberto code : it's ok.
Thanks for your help (Roberto & Wim).

Have nive day.

Vincent

0 Kudos
Message 6 of 6
(6,021 Views)