LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

invalid control id

Hi,

I'm getting an invalid control ID.  The situation is as follows:  I have a main panel that is the main parent, on this panel, i have a tab control (consisting of one or more tabs).  On each of the tab control there is a panel that i call baseTabPanel which is a child of mainPanel.  On tab_panel I have one or more child panels which I call motorGroupPanel, these panel(s) are children of the baseTabPanel.  The code fails on the line in red (see snippets below), and the error is 

"NON-FATAL RUN-TIME ERROR:   "motorcontrol_ui.c", line 174, col 5, thread id 0x00000E2C:   Library function error (return value == -13 [0xfffffff3]). Invalid control ID"

I have double, and triple-checked the control IDs and they are correct, and give the same values when I 'mouse-over' during debug as the values in the .uir file.

Anyways, Here is the code snippets from main and on:

int main (int argc, char *argv[])
{

    if (InitCVIRTE (0, argv, 0) == 0)
        return -1;    /* out of memory */

    if(populateUI() < 0)
        return -1;
   
....

}

static int populateUI(void)
{
    unsigned int i;
    unsigned int numMotorGroups;
    static const unsigned char numGroupsPerPage = 8;    //number of motorGroups to be displayed on one page
    static int mainPanel;        //panel that holds everything

    return(makeFirstPage(&mainPanel));    //make the first page

...

}

static int makeFirstPage(int *mainPanel)
{
    static int baseTabPanel;    //panel that resides on each tab
    static int motorGroupPanel;    //panel that each motor group resides on

    struct
    {
        int height;
        int width;
        int top;
        int left;
       
    }mainPanelAttr;

    //load the main Panel that holds everything
    if ((*mainPanel = LoadPanel(0, "motorcontrol_ui.uir", MAIN_PANEL)) < 0)
        return -1;

    //load the base-level panel that resides on each tab
    if((baseTabPanel = LoadPanel(*mainPanel, "motorcontrol_ui.uir", TabPANEL)) < 0)
        return -1;
       
    //load the panel that holds each motor group
    if((motorGroupPanel = LoadPanel(baseTabPanel, "motorcontrol_ui.uir", MtGrpPnl)) < 0)
        return -1;
   
    //Get the top, left position and width, height of the main panel to set the child UI components to
    GetCtrlAttribute(*mainPanel, MAIN_PANEL, ATTR_LEFT, &mainPanelAttr.left);   FAILS HERE
    GetCtrlAttribute(*mainPanel, MAIN_PANEL, ATTR_TOP, &mainPanelAttr.top);   
    GetCtrlAttribute(*mainPanel, MAIN_PANEL, ATTR_HEIGHT, &mainPanelAttr.height);
    GetCtrlAttribute(*mainPanel, MAIN_PANEL, ATTR_WIDTH, &mainPanelAttr.width);

       
    //Set the Top, left, width and height of base-level panel to the same as the mainPanel
    SetCtrlAttribute(baseTabPanel, TabPANEL, ATTR_LEFT, mainPanelAttr.left);
    SetCtrlAttribute(baseTabPanel, TabPANEL, ATTR_TOP, mainPanelAttr.top);   
    SetCtrlAttribute(baseTabPanel, TabPANEL, ATTR_HEIGHT, mainPanelAttr.height);   
    SetCtrlAttribute(baseTabPanel, TabPANEL, ATTR_WIDTH, mainPanelAttr.width);   

    //set the Top, left of the motor group panel to the same as the mainPanel
    SetCtrlAttribute(motorGroupPanel, MtGrpPnl, ATTR_LEFT, mainPanelAttr.left);
    SetCtrlAttribute(motorGroupPanel, MtGrpPnl, ATTR_TOP, mainPanelAttr.top);
   
    //Display the main Panel
    DisplayPanel(*mainPanel);
   
    //Display the base-level tab panel
    DisplayPanel(baseTabPanel);
   
    //Display the motor group panel
    DisplayPanel(motorGroupPanel);
   
    return 0;
}
0 Kudos
Message 1 of 5
(5,141 Views)

You are simply using GetCtrAttribute to retrieve a panel attribute, passing the panel ID as the control ID. This obviously cannot work.

I suggest you to use GetPanelAttribute (*mainPanel, ATTR_LEFT, &mainPanelAttr.left);



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 2 of 5
(5,132 Views)
Thanks! That worked.
I confused the panel ID with the control ID.

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

Hello

 

I'm a newbie labwindows,

 so i'm having the same error i have two pannel when i press paue still the same erro here is a preview of the code and a pic of the panel

 

"


int CVICALLBACK PauseCB (int panel, int control, int event,
                         void *callbackData, int eventData1, int eventData2)
{
    switch (event)
    {
        case EVENT_COMMIT:

         PauseFlag = TRUE;
         /*Timer Disabled When User Pauses*/
        
          SetCtrlAttribute (panelHandle,TABPANEL_TIMER,ATTR_ENABLED,0);
         SetPanelAttribute(TABPANEL_TIMER, ATTR_ENABLED,0);   
         TimerEnabled = FALSE;
         /*Timer Disabled When User Pauses*/
         
         /*Disable Use of Read/Write when timer is "paused"*/
         SetCtrlAttribute (panelHandle, TABPANEL_gpibwrt, ATTR_DIMMED,1);
         SetCtrlAttribute (panelHandle, TABPANEL_gpibwrt, ATTR_DIMMED,1);
        
         /*Disable Use of Read/Write when timer is "paused"*/
         
         SetCtrlAttribute (panelHandle, TABPANEL_CONTINUE, ATTR_DIMMED, 0);
         SetCtrlAttribute (panelHandle, TABPANEL_PAUSE, ATTR_DIMMED, 1);
         
            
            break;
        case EVENT_RIGHT_CLICK:

            break;
    }
    return 0;
}

 

"

 

 

0 Kudos
Message 4 of 5
(4,471 Views)

Does the panelHandle variable that you're passing to the SetCtrlAttribute functions hold the tab panel id ("Tab Configuration") or the main panel id ("GPIB Communication")? My guess is that it holds the main panel id. You need to pass the tab panel id to those functions.

 

You can get the tab panel from the main panel by calling the GetPanelHandleFromTabPage function, or in this case, since it looks as if the pause button is in the same tab panel, you could just pass the panel variable that is passed to your PauseCB callback function.

0 Kudos
Message 5 of 5
(4,451 Views)