LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Tab Control Question CVI 8.0.1?

I have a created a Tab control on my panel that has about 8 labels on the tab.
 
What am I trying to do is on my startup I am trying to keep the first seven labels un-selectable, while letting the 8th label be selected.
 
I have figured out that I can dim the tab at the start of the application and all controls tied to that label are dimmed and not selectable, but does not prevent the labels themselves from being selectable.
 
My question is how can I make the first seven labels in a tab control not selectable and let the eighth label be selectable?
 
I am just trying to figure out how to do this programmatically.
 
Thanks
0 Kudos
Message 1 of 5
(3,751 Views)
Unfortunately there is no property to deactivate single Tab-pages. You could either remove all deactivated pages, or Set them invisible.
If you want all Tab Pages to be visible and still have some Pages that are not selectable, the only thing I can think of iis doing it programmatically. The Tab Control can fire a Event whenever the User selects a new Tab-Page (EVENT_ACTIVE_TAB_CHANGE). eventData1 contains the index of the previous selected page, eventData2 contains the index of the page the user selcted. You could use a array of flags, defining which pages are active and which are not:
activetabs[0]=0;
 activetabs[1]=0;
 activetabs[2]=0;
 activetabs[3]=0;
 activetabs[4]=0;
 activetabs[5]=0;
 activetabs[6]=0;
 activetabs[7]=1;
0 = not active, 1 = activ, so in this case, aonly the last page is active.
In the Callback of your TabControl you would have to implement the following code:
 
int CVICALLBACK tabCanged (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
 switch (event)
 {
  case EVENT_ACTIVE_TAB_CHANGE:
   if(activetabs[eventData2]==0)
   {
       SetActiveTabPage (panelHandle, PANEL_TAB, eventData1);      
   }
   break;
 }
 return 0;
}
 
So whenever the user selcts one of the "disabled" pages, the callback will set the last selected page as the active page again.
 
 
 
Hope this helps. Attached you can find an example.
 
André
 
0 Kudos
Message 2 of 5
(3,735 Views)

Thanks that was a great example.

The only question that I have left is when the user selects the dimmed tab, the tab will be visible for just a second until the code kicks in and puts the tab back to the original.

Is there anway in the tab callback function to get the event to be ignored and not change the active tab at all?

I know in my code and in the example code there is a split second between the event tab change and the programmatic setback of the active tab.

I am just trying to eliminate that brief flash on the tab. Could be considered a little confusing to the user.

Thanks for the help.

 

 

 

 

0 Kudos
Message 3 of 5
(3,712 Views)

have a look at the attached C-File. It contains a better solution, using Event Swallowing. You shouldn´t see any flickering here...

 

André

 

Message 4 of 5
(3,688 Views)

Thanks.

It works like a charm.

Thanks again.

 

 

0 Kudos
Message 5 of 5
(3,681 Views)