control chnages in a dialog MFC

Hiya

Suppose I have a dialog with numerous controls in it e.g. edit boxes, radio buttons, check boxes.

Is there a simple way for me to find out if the dialog is opened, controls modified e.g. values in edit boxes changed or radio button selections changed, and then closed. That is, is there a way to determine whether values or changed or not during the opening and closing of the dialog?

I could of course look at the OnChange message for each control in the dialog but if there are many controls this maybe difficult and time consuming. It also doesn't deal with the issue of changing a value and then re-setting it to its original before leaving the dialog i.e. no changes have been made.

Any ideas?

John
IssacJonesAsked:
Who is Participating?
 
AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
You would have to code something yourself.


Possibly have a struct (class) with the original settings - use the OnInitDialog to copy those values into the controls.
When the dialog is closed you can use UpdateData to find the current settings - now compare the initial setting when the current settings.
0
 
pgnatyukCommented:
Another idea is to add a boolean (integer) variable that becomes true when the user changes any data. This variable becomes false when the changed values were saved/handled.
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
@pgnatyuk - good idea to flag a change simply, but it fails on following requirement I think:

 >>It also doesn't deal with the issue of changing a value and then re-setting it to its original before leaving the dialog i.e. no changes have been made.
0
 
DanRollinsConnect With a Mentor Commented:
As AndyAinscow says, it requires special programming... there is no quick/easy solution.
There is typically an area in the code, right before the DoModal() call,  that sets member variables from some external source (the registry, for instance).   Since all the pre-set values are listed together there, you can use that part of your code to help in creating your own IsDirty() function.  
0
 
IssacJonesAuthor Commented:
Thanks guys
0
All Courses

From novice to tech pro — start learning today.