07-08-2016 02:03 AM
Hello everybody !
I have to create a quit button to quit my program! I have a start button too. However, the program run when I put on Quit Button once and when I put twice it quit the program. When I put Start Button nothing happens even if my main code is into.
My code of Quit Button is :
int CVICALLBACK QuitCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
QuitUserInterface(0);
break;
case EVENT_RIGHT_CLICK:
break;
}
return 0;
}
Can I have help? Why my QuitCallback button do that ?
07-08-2016 02:11 AM - edited 07-08-2016 02:11 AM
It is difficult to say what's happening without looking at the entire code: the quit callback looks correct, that must be some other reason for this behaviour.
Is the program multithreaded? Is it operating a long-lasting function while you press the quit button the first time? Is there one RunUserInterface only in the program?
07-08-2016 02:46 AM
I have a RunUserInterface() on my timer if I put this function on my start button it will work in your opinion?
07-08-2016 02:56 AM
That looks strange to me: the recommended structure of a CVI program has no RunUserInterface inside control callbacks!
Look at some of the examples that ship with CVI for examples of a regular CVI framework.
Can you post your code?
07-08-2016 03:05 AM
int CVICALLBACK StartMot (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
int i;
ComWrt(1,"\r",StringLength("\r"));
for(i=1;i<360;i++)
{
/* begin the rotation */
ComWrt(1,"SK(i)",StringLength("SK(i)"));
ComWrt(1,"\r",StringLength("\r"));
/* stop the measure */
ComWrt(1,"CP(i)",StringLength("CP(i)"));
ComWrt(1,"\r",StringLength("\r"));
break;
}
GetCtrlVal(panelHandle,PANEL_intervalTimer,&IntervalTimer);
return 0;
}
return 0;
}
int CVICALLBACK ActiveTimer (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
//ResetTimer(0,0);
RunUserInterface();
ResumeTimerCallbacks();
SetCtrlAttribute(panelHandle,PANEL_TIMER,ATTR_ENABLED,1);
break;
case EVENT_RIGHT_CLICK:
break;
}
return 0;
}
This is my code.
So, you think I should delete RunUserInterface ?
07-08-2016 03:20 AM - edited 07-08-2016 03:20 AM
Of course you need to!
And there's a lot of mistakes in your code, I don't even know where to start with!
First of all, what's the purpose of the timer?
And why putting ResumeTimerCallbacks and SetCtrlAttribute (...ATTR_ENABLED)inside the timer callback? If the timer were not enable or suspended the callback won't even fire!
You should seriously consider taking some basic cource on CVI: NI offers both frontal and online courses on the product: see Customer Education page for reference. At least you should run through the tutorial that gets installed on your machine.
07-11-2016 04:31 AM
I found the solution ! it wasn't the quit button