LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid Control ID

I have a drop down ring control that selects different tests.

One selection is manual. Manual enables a text string for sending data out a serial port and it sets the fucus to this item:

 

SetActiveCtrl (panel, PANEL_MAIN_TX_STRING);
This is on the main panel.

 

When the user presses other buttons like the Power button I want the focus to retun to the PANEL_MAIN_TX_STRING when the ring control is set to Manual.

 

I added this code to the POWER callback:

 

GetCtrlIndex (panel, PANEL_MAIN_TEST, &index); ****THIS is where the error occurs.
if ( index == SM_MANUAL_ST1)
{
     SetActiveCtrl (panel, PANEL_MAIN_TX_STRING);
}

 

This works except when I press the Quit button I get a NON-FATAL RUN-TIME ERROR Invalid ID control.

 

QUIT callback(.......)

{

 

case EVENT_COMMIT:

SuspendTimerCallbacks ();


/* Turn off CCU Power */
SetCtrlVal (panel, PANEL_MAIN_POWER,
0);
CallCtrlCallback (panel, PANEL_MAIN_POWER, EVENT_COMMIT,eventData3, eventData4, &returnValue);
QuitUserInterface(0);
break;

 return (0);

 

The stack trace shows:

Power

main

 

The error occurs in the Power callback not the Quit callback.

 

Why does CVI think that control does not exist?

 

Thanks.

0 Kudos
Message 1 of 13
(5,221 Views)

Hi Nubie,

 

Is your Quit button on a separate panel or same panel with your ring control? 

S. Eren BALCI
IMESTEK
0 Kudos
Message 2 of 13
(5,220 Views)
All the buttons are on the same panel.
0 Kudos
Message 3 of 13
(5,217 Views)

Are you saying that the only time you get the error is when you press the Quit button?

Under what event is is your call to GetCtrlIndex()?

Are you sure that PANEL_MAIN_TEST is the correct spelling for the drop down ring and that "panel" is the panel handle for the main panel?

Is it possible that your panel handle "panel" is getting reused by another panel?

In the Quit callback, why do you set the main power control and then call its callback?  It would be cleaner if you created a separate power up/down function that you could call from the main power callback or from the Quit callback.

What timers do you have running that you need to SuspendTimerCallbacks in your Quit callback?

 

It may help if you post more of your code.

0 Kudos
Message 4 of 13
(5,207 Views)
Is the code you have put in the POWER callback invoked for all events, or only for the EVENT_COMMIT event? It should be the latter.
--
Martin
Certified CVI Developer
0 Kudos
Message 5 of 13
(5,184 Views)

I know this thread is over a year old, but it doesn't look like it was ever solved, and I was experiencing a very similar problem.

 

In my code, I have a tab control and was using a timer on one of the tabs.  Although the timer was only enabled when that tab was active, my timer callback seemed to execute on call to QuitUserInterface(0) regardless of what tab was active and whether the timer was running or not.  In this instance only, some of the controls referenced in the timer callback via GetCtrlVal and SetCtrlVal threw that error, and worked properly at all other times.

 

I solved the problem by moving the timer from the tab panel to my main panel.  Not sure why this was an issue, but it works now so I'm happy!

0 Kudos
Message 6 of 13
(4,747 Views)

Hi AbsolutelyAndrew,

who tells the timer is only executing when a specific tab is active? A timer control runs its callback until it is disabled, regardless it is on a regular panel or on a tab page; to have it stop working you must set e.g. SetCtrlAttribute (panelHandle, PANEL_TIMER, ATTR_ENABLED, 0); or use SuspendTimerCallbacks (); Are you using either of these in your code to enable/disable the timer?



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 13
(4,729 Views)

My start and stop timer functions:

 

void StopIMUTimer(void)
{
    SetCtrlAttribute(panelHandle,PANEL_IMU_TIMER, ATTR_ENABLED, 0);    //Stop Timer    
}

void StartIMUTimer(void)
{
    ResetTimer(panelHandle,PANEL_IMU_TIMER);
    SetCtrlAttribute(panelHandle,PANEL_IMU_TIMER, ATTR_ENABLED, 1);    //Start Timer    
}

 

I'm using the callback generated by the tab control.  For EVENT_ACTIVE_TAB_CHANGE, if the tab in question is active, the timer is started.  If it is not active, the timer is stopped.

 

Using this methodology, no timer callback should occur after StopIMUTimer(), correct?

 

 

0 Kudos
Message 8 of 13
(4,725 Views)

Yessss... provided the function executes with no errors!

You may be running into the usual problem with controls over a tab page: what is panelHandle variable holding? Are you ever retrieving the handle of the tab page the timer control is on with GetPanelHandleFromTabPage? You may want to trap the return value of SewtCtrlAttribute and check whether it is zero or not.



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 9 of 13
(4,721 Views)

It is indeed possible for the stop function to execute with errors and go unnoticed.  However, I am skeptical that that is what is occuring.  It's not apparent from the code snippet, but on startup, all tab panel handles are acquired via GetPanelHandleFromTabPage and stored in unique variables.

 

I put a breakpoint in the timer CB and verified that during ordinary operation things work fine. It is not until QuitUserInterface() that the CB executes.

0 Kudos
Message 10 of 13
(4,715 Views)