WinMerge stores options into registry:
HKCU/Software/Thingamahoochie/WinMerge
Several subkeys exists for different kind of options. Settings
subkey is
good place for most options. There are several subkeys for different sets of options,
e.g. custom colors have their own subkey. If you need one single new option, put it
top Settings
subkey. If you need a new set of options for e.g. font setting,
create a new subkey for them.
Two ways to read and save options:
GetProfileInt()
, GetProfileString
,
WriteProfileInt()
& WriteProfileString()
).
COptionsMgr
class (recommended)This is handy for settings needed in few events or cases. Especially when
COptionsMgr
is not available, e.g. early in startup of WinMerge.
However this method misses all advantages of COptionsMgr, like import/export and
caching. So it should be used only when really necessary.
Using COptionsMgr
is recommended for all new options. Also all options
visible in Options-dialog must use COptionsMgr
. Currently there is one
COptionsMgr
(or actually CRegOptionsMgr
) instance in CMergeApp
.
Using COptionsMgr
is pretty simple and straightforward:
OptionsDef.h
.CMergeApp::OptionsInit()
, located in OptionsInit.cpp
.
When initialised, type is determined and default value given. If option with that name
does not yet exist, new one is created.
COptionsMgr::GetBool()
, GetInt()
or GetString()
.COptionsMgr::SaveOption()
. Note that value is saved to registry immediately.COptionsMgr::GetDefault()
COptionsMgr::RemoveOption()
OptionsDef.h
. Please try to keep
options organised in registry, although all existing options aren't.
And use meaningful names for options.
CMergeApp::OptionsInit()
, with sensible
default value. Remember default value is what most users see when first
time using WinMerge or new feature using it. So it really must be good
for normal use.
GetX()
functions to read values and SaveOption()
to store values.There are some very frequently used option values, like color values for
editor syntax highlight. Reading and writing these kind of values through
COptionsMgr
every time would be pretty inefficient. So we only read them
to local variables when needed and store when they are changed.
OptionsDialog (CPreferencesDlg
) receives pointer to COptionsMgr
when
initialised for access to options.
Note:All propertypages in OptionsDialog may not have GUI initialized, so remember to check window existence before trying to access it (get values/update it).
Options-propertypages implement IOptionsPanel
interface. ReadOptions()
and WriteOptions()
must be implemented by all options-propertypages. Their functionality
should be clear... CPreferencesDlg
calls those functions when loading and saving options.
If propertypage has 'Defaults' button it needs pointer to COptionsMgr
. Usually it is
easiest to give it in constructor. Then page can call COptionsMgr::GetDefault()
for options it
wants to reset to defaults when button is selected.