Programming in Windows with Visual Studio 2010 C++ and MFC. My question is about how best to store, update, and pass around program settings or options.
I have a simple main GUI window/frame/dialog. On that main window I have an options button. When I click the options button I create an Options Dialog.
Inside the options dialog I get a reference to the "application" (an MFC concept, globally available) and grab a reference to my custom settings class (an instance is stored in the application class. From there, I can populate my options dialog and save my options back.
Perhaps I should be using Dependency injection to inject the settings into my option dialog? Or perhaps I should not even be accessing the settings from within the dialog class? MaybeI should expose the settings via set/get on the dialog class?
Also, now I want to show some options right there on the main window, while still keeping them settable on the original options dialog. So now I'm wondering what a good design is for this. If I set an option on my options dialog I want it to update the options displayed on the main window.
I guess this is a good spot for the Observer pattern but I'm trying to figure out how to piece it altogether in a MFC context (which as best as I can tell is basically pretty much the same as any other GUI toolkit in any other language, so if you're not into MFC I still want your comments)
- How should I be passing my settings around?
- How do I keep the GUI display of the settings in sync with each other? Such that after clicking OK on the options dialog box, the options directly shown on the main window are updated?