ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Panel Label

I am in a trouble when I tried to set the label of a chart.

The function that I use to create the chart is listed below:

And there are some global variables, such as:

int panelHandle;     // Main panel ID
int tabControlID;     // TabControl ID
int activeIndex;       // Active tab index
int tabPanelHandle;// ID of the active tab

void CreateObject ( char controlFile[], int *newPanelID) {
         GetPanelHandleFromTabPage(panelHandle, tabControlID, activeIndex, &tabPanelHandle);
         *newPanelID = LoadPanel(tabPanelHandle, controlFile, PANEL); 
         DisplayPanel (*newPanelID);
}


This is the function that I use to do the interface with the user.
int CVICALLBACK pressedIndicatorButton (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    int newPanelID;
    char label[10] = "test";
...
   CreateObject (controlFile, &newPanelID); 
   SetCtrlAttribute (panelHandle, newPanelID, ATTR_LABEL_TEXT, label);
...
}

The line in bold causes the error.

The chart is in a TabControl.

What is going wrong?

The error message is: "...Invalid control ID"

Thank you in advance.
0 Kudos
Message 1 of 7
(4,671 Views)
I solve the problem doing something like that:

                       
                        CreateObject (controlFile, &newPanelID); 
                     
                        GetLabelFromIndex ( pPanel, PARAMETER_TREE, val, label );
                        GetPanelAttribute (newPanelID, ATTR_PANEL_FIRST_CTRL, &controlAux);
                        SetCtrlAttribute (newPanelID, controlAux, ATTR_LABEL_TEXT, label);
0 Kudos
Message 2 of 7
(4,651 Views)

This error arises because you are passing a panel handle as a control ID and are using the wrong panel handle in SetCtrlAttribute.

Once you CreateObject function has created the new panel, it returns its panel handle: this is the handle to pass as the first parameter in SetCtrlAttribute. The control ID is then simply the name of the control, so if your anel is PANEL and supposing the chart is named CHART, you should use

SetCtrlAttribute (newPanelID, PANEL_CHART, ATTR_LABEL_TEXT, label);



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 7
(4,642 Views)
We are in a trouble with the following code. We have defined an initial panel which contains a TAB control. We are trying to get the value of a control defined on one of the tab pages but we obtain an error message saying "Invalid control ID" (referred to the second parameter of the function GetPanelHandleFromTabPage). Find below part of the written code. Thanks for advanced
 
 
 NON-FATAL RUN-TIME ERROR:   "Configuracion_Equipos.c", line 24, col 13, thread id 0x00000650:   Library function error (return value == -13 [0xfffffff3]). Invalid control ID
 
GetPanelHandleFromTabPage (SmlConfig, SmlConfig_TAB, 0, &Tab_uso);
GetCtrlVal (Tab_uso, TABPANEL_5_OnOf_Ampli1,&EstadoAmpli1);
0 Kudos
Message 4 of 7
(4,394 Views)

Unless you have defined a panel handle with the same name as the panel itself as defined in the UIR editor (which is forbidden by the compiler Smiley Wink ), I see a problem in GetPanelHandleFromTabPage (SmlConfig, SmlConfig_TAB, 0, &Tab_uso);

The first parameter to this function must be the panel handle, that is the value returned from LoadPanel:

int   SmlConfigHandle;

SmlConfigHandle = LoadPanel (0, "MyFile.UIR, SmlConfig);
...
GetPanelHandleFromTabPage (SmlConfigHandle, SmlConfig_TAB, 0, &Tab_uso);
GetCtrlVal (Tab_uso, TABPANEL_5_OnOf_Ampli1,&EstadoAmpli1);


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 5 of 7
(4,386 Views)
Hi Roberto,
we have already done the step but we are still having problems with SmlConfigHandle. We have defined the variable in another .c file as follows :
 
static int panel_config_equipos;
....
....
...
panel_config_equipos=LoadPanel (0, "Configuracion_Equipos.uir", SmlConfig);
 
When we try to run the hole programm arises again the problem: "panel_config_equipos unknown". We have tried as well to defined this variable as external into the initial .h file but it still doesnt work.
 
#include <userint.h>
#ifdef __cplusplus
    extern "C" {
#endif
     /* Panels and Controls: */
#define  PANEL                           1

     /* Menu Bars, Menus, and Menu Items: */
#define  MENUBAR                                   1
#define  MENUBAR_EXTRAS                  2
#define  MENUBAR_EXTRAS_CONFIG_EQUIPOS   3       /* callback function: Config_equipos */
#define  MENUBAR_EXTRAS_Salir             4                     /* callback function: Salir_Principal */
#define  MENUBAR_CALIBRACION             5
#define  MENUBAR_AYUDA                         6
#define  MENUBAR_AYUDA_ACERCA        7       /* callback function: Acercade */
#define  panel_config_equipos                      8
 
 
     /* Callback Prototypes: */
void CVICALLBACK Acercade(int menubar, int menuItem, void *callbackData, int panel);
void CVICALLBACK Config_equipos(int menubar, int menuItem, void *callbackData, int panel);
void CVICALLBACK Salir_Principal(int menubar, int menuItem, void *callbackData, int panel);

#ifdef __cplusplus
    }
#endif
 
Could you please give us some hints?? Thanks
0 Kudos
Message 6 of 7
(4,359 Views)

As far as I can understand, your configuration function is called from a menu loaded on the same panel where the tab control is on. If this is the case, the panel handle is passed to the menu callback as the last parameter, and you can directly use 'panel' instead of your panel_config_equipos variable. The same happens if you were using a command button instead of a menu item: the panel handle is passed as the first parameter to the button callback.

As per defining global variables (i.e. variables usable from multiple .c files in your process) there are several threads in the forum that discuss this argument: here one sample discussion that you may want to read.



Message Edited by Roberto Bozzolo on 03-03-2008 09:02 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 7 of 7
(4,355 Views)