LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Exit without saving?

Solved!
Go to solution

Hello everyone, I have a panel with 13 numeric controls, a save button and a close button.
I want to make sure that if  I made ​​changes and click close button without first saving, appears a pop-up "you want to exit without saving?" But if I did not change the panel closes with no messages pop up. 
How can I do? Thanks

0 Kudos
Message 1 of 3
(3,046 Views)
Solution
Accepted by topic author ViperNaples

This is a common problem for settings panels: my personal solution to do that is made in a few steps that I describe below. I would like to know how other programmers face this item.

 

 

Step 1:

When designing the panel, set the Save button as dimmed.

Install on all controls the operator can modify the same callback function:

int CVICALLBACK ParametersModified (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	if (event != EVENT_VAL_CHANGED) return 0;

	if (callbackData)
		SetInputMode (panel, (int)callbackData, 1);

	return 0;
}

 

Step 2:

When loading the panel, set the ID of the save button as callbackData on all controls in the panel, this way:

SetCtrlAttribute (panelHandle, PANEL_CONTROL1, ATTR_CALLBACK_DATA, (void *)PANEL_SAVE);

Set the same callbackData on Quit button too.

 

 

When the user changes the value of any control, the system automatically will fire ParametersModified callback with EVENT_VAL_CHANGED event, which will undim the Save button.

 

 

Step 3:

When the user presses Quit button, test the dimmed state of the Save button and ask to save/discard in case it is not dimmed.

 

 

This procedure is quite general so that ParametersModified callback can be used on different panels in your application since the Save button ID to manipulate is passed to it as a parameter.



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?
Message 2 of 3
(3,041 Views)

Thanks a lot Roberto !!!

0 Kudos
Message 3 of 3
(3,034 Views)