07-18-2011 04:59 PM
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
Solved! Go to Solution.
07-18-2011 11:57 PM
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.
07-19-2011 03:03 AM
Thanks a lot Roberto !!!