06-14-2018 10:56 AM
Hi there !
I would like to make a text blink thanks to a timer callback. Here is the code of my timer (which has a period of 1sec) callback:
int CVICALLBACK REFRESH(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if (bool==1) { bool=0; SetCtrlVal(atlas, PANEL_txt, " "); } else { bool=1; SetCtrlVal(atlas, PANEL_txt, "ESSAI EN COURS"); } return 0; }
My code is compilling and the blinking is working. However, when I close the program, I get an error on this line :
SetCtrlVal(atlas, PANEL_txt, " ");
with the error message "Library function error (return value ==-13). Invalid control ID ". Do you know where from it could be ? Or do you have another idea to make the text blink ?
Thank you in advance !
Solved! Go to Solution.
06-14-2018 01:13 PM
Timer controls generate two events: an EVENT_TIMER_TICK at every time interval and an EVENT_DISCARD when the panel containing the timer is discarded. It appears that when you close your program, the EVENT_DISCARD calls your callback and tries to operate a control on a panel that you've previously discarded.
To prevent this, only execute the code in your timer callback when the event is EVENT_TIMER_TICK:
int CVICALLBACK REFRESH(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if (event == EVENT_TIMER_TICK) { ... } }
06-15-2018 06:46 AM
Thank you so much for your answer, now it is working !