LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

quit button

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 ?

0 Kudos
Message 1 of 7
(4,336 Views)

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?



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 2 of 7
(4,335 Views)

I have a RunUserInterface() on my timer if I put this function on my start button it will work in your opinion?

0 Kudos
Message 3 of 7
(4,330 Views)

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?



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 4 of 7
(4,327 Views)

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 ?

0 Kudos
Message 5 of 7
(4,322 Views)

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.



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 6 of 7
(4,317 Views)

I found the solution ! it wasn't the quit button

0 Kudos
Message 7 of 7
(4,282 Views)