Add a timer to your program:
1. In the UI Editor, right-click on empty space in your panel and select Timer.
2. Double-click on the timer to edit the control.
2.1 Add a Callback Function name, e.g. TimerCallback.
2.2 The default timer interval is 1 second. If you want to update your display at a different rate, change the Interval.
2.3 If you want to change the timer label from Untitled Control, change it. (The label isn't used by anyone. The user won't see it at run-time).
2.4 Click OK to stop editing the control and return to the UI Editor.
3. Right-click on the timer and select Generate Control Callback.
4. Right-click on the timer and select View Control Callback.
5. Do something like this to get and format the time and date.
int CVICALLBACK TimerCallba
ck (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
char timeAndDate[80];
switch (event)
{
case EVENT_TIMER_TICK:
sprintf (timeAndDate, "%s %s", TimeStr (), DateStr ());
SetCtrlVal (panelHandle, PANEL_TIMESTRING, timeAndDate);
break;
}
return 0;
}