CPreference is an abstract class that aids in loading preference files and resources. To see how elegant it is to use, check out CReducePrefs in Reduce3D. It is a subclass of CPreference, with tons of preference variables, but there is essentially no programming needed to handle them. It is also very simple to modify the default preference resource in the application. Upon program launch, when the CPreference object is created, holding down [Shift] will bring allow you to choose your resource file, and a new resource with the current programmatic defaults is put into the file. When you next compile the program, the revised resource gets put into the built application. It also will check the version of the preferences against the current version stored in the 'vers' resource of the application, and if the prefs file is old, will make a new one with default values.

This grew out of CPreferences, submitted to the Metrowerks PowerPlant class archive by Richard Bray in 1994, but I have made extensive modifications.

Source Code

 

-Dave Hirsch