LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Close Alt-F4 CVI

Closing an application written in CVI 6.0. A difference exists in behaviour between clicking on the 'X' on the application and right clicking and selecting Close from the Taskbar. Why is this? (In debug mode it didn't go through the exiting callback function when the taskbar method was used)
0 Kudos
Message 1 of 2
(3,142 Views)
Brian,

You are right, there is a difference when you close the pannel with the "x" or Alt + F4 that when you just right-click in the task bar and close it. The main difference is that in the first case the CVI built panel has "focus" so the panel is able to catch the event and process it. When you use the task bar then the focus is set on the taks bar and the panel does not gets the event.

However there is a way to catch the event that gets generated when the user uses the taskbar to close the application, the task manager or the user simply closes windows. You needto install a Main callback, this is a function that receives all of the application events (more info on this in the help file). Here is a small piece of code that will allow you to setup a main cal
lback that handles the EVENT_END_TASK event that gets generated when the application is forced to close. In this callback you can just call you "Quit" callback or just swallow the event (just return 1) and the application will ignore the event.

/*after loading the panel just install the main callback to handle the event*/
InstallMainCallback (MainCallBack, 0, 0);


/*define the callback function and catch the EVENT_END_TASK*/


int CVICALLBACK MainCallBack (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
if (event == EVENT_END_TASK)
{MessagePopup ("MAIN CALLBACK",
"This the message from the main callback funbction.....\n have a nice day");
return 1; /*return 1 if you want to ignore the event */
}
return 0;
}

I hope this helps, let me know how this goes.

Regards,

Juan Carlos
N.I.
0 Kudos
Message 2 of 2
(3,142 Views)