LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Panel titles are missing after EasyTab_RemovePanel and EasyTab_AddPanel

I need to remove some panels and then add the panels back in.  When I initially build the Panels I set the titles using a EasyTab_SetAttribute call.  So I did an EasyTab_RemovePanel and then after some operator switch actions I add the Panels back in using a EasyTab_AddPanels call.  I noticed that the titles of the Panels that I removed were missing.  So I added a EasyTab_Set Attribute call before the EasyTab_AddPanels and this did not work.   Can anyone tell me what I am doing wrong and why this doesn't work?
Thanks,
Donna
 
Here is my code. 
// Code to remove the panels and save the titles
 for (int pan_ix = 1; pan_ix < 7; pan_ix++)
        EasyTab_RemovePanel(offline_test_menu, tabCtrl, offline_subpanels[pan_ix].panel_id);
 
// Code to add the panels back in with their titles
 for (pan_ix = 1; pan_ix < 7; pan_ix++)
{
    // I used a debugger to ensure that text has the appropriate title
     error = EasyTab_SetTabAttribute (offline_test_menu, tabCtrl, offline_subpanels[pan_ix].panel_id,
    ATTR_EASY_TAB_LABEL_TEXT, text);
   error = EasyTab_AddPanels
           (offline_test_menu, tabCtrl, row_ix, offline_subpanels[pan_ix].panel_id, 0);
}
0 Kudos
Message 1 of 3
(3,038 Views)

Hi Donna,

The problem is that when the tab panel is removed, the handle for it is no longer valid.  Think of it as using a DiscardPanel call on a panel.  There are two things that you can do to fix this.  First, in the code that you already posted, the following change should work. 


// Code to add the panels back in with their titles
 for (pan_ix = 1; pan_ix < 7; pan_ix++)
{
    /*Swap the original two functions*/
  error = EasyTab_AddPanels
           (offline_test_menu, tabCtrl, row_ix, offline_subpanels[pan_ix].panel_id, 0);
    // I used a debugger to ensure that text has the appropriate title
     error = EasyTab_SetTabAttribute (offline_test_menu, tabCtrl, offline_subpanels[pan_ix].panel_id,
    ATTR_EASY_TAB_LABEL_TEXT, text);
}

Moving the 'EasyTab_SetTabAttribute' to after you load the panels call should give you the proper effect.  Also make sure that you are getting the newest ID's of the easy tab panels when you reload them.

A second option, and this might not work for you depending on your situation, but it may save you some coding, is to hide the panels instead of removing them.  You can do this with the  'EasyTab_SetTabAttribute' function using the 'ATTR_EASY_TAB_VISIBLE' attribute.

0 Kudos
Message 2 of 3
(3,033 Views)

Thanks Dave,

  I tried  your first option and it worked!

Donna

0 Kudos
Message 3 of 3
(3,027 Views)