|Command Using Persisted Settings
This command button works with the 'Persist Settings Using IPersistStream' and the
'Persist Settings Using IPersistVariant' extensions. It is enabled when one of these
extensions is registered and enabled.
These extensions store a default map background color setting that is applied when a document opens
and when dataframes are added or deleted. They also store default view preferences for the TOC
and the map that are applied when a document opens. The command button opens up a dialog through
which users can modify these settings.
How to use:
Initial Setup (Visual C++):
Open this sample's workspace and change the paths to esriCore.olb and ArcCATIDs.h in StdAfx.h so that they point to your ArcGIS installation.
Build this sample's DLL. This will also register the command in the appropriate component category.
In ArcMap's Customize dialog, under the Commands tab, select 'Persist Settings Command' from the Developer Samples category, and drag it on to a toolbar. Dismiss the Customize dialog.
Make sure that either the 'Persist Settings Using IPersistStream' extension or the 'Persist Settings Using IPersistVariant'
extension is registered and enabled. For information on how to do this, consult the respective samples.
Initial Setup (Visual Basic):
In ArcMap, open the Customize dialog. Click on 'Add from file' and select this sample's dll.
Under the Commands tab, select 'Persist Settings Command (VB)' from the Developer Samples category, and drag it on to a toolbar. Dismiss the Customize dialog.
Make sure that the 'Persist Settings Using IPersistVariant (VB)' extension is registered and
enabled. For information on how to do this, consult that sample.
Using the command:
Open a new document. Notice that the dataframe has a background color. Also notice that the
TOC is in the Source view and the map is in the Layout view. This is due to the settings applied by the
Persist Settings Extension.
Add a new data frame by going to the 'Insert' menu. Notice that this dataframe has a background color too.
Click on this command button to bring up a dialog which displays the current choice of active view,
TOC view and map background color.
Change these settings, and hit 'Save Settings'. You will notice that the changed settings
have been applied to your document.
Save your map document and close it. Open it again and notice the effects of your changes.
Try doing the same with a map template.
When you are done, remove the extension you made active. To do this, unregister the extension's
DLL by typing "regsvr32 /u <path_to_the_extension's_dll>" at a DOS prompt. Also remove the command button.
||Class file that implements the command.
||Form brought up by the command.
||Resource file for the bitmap used by the command.
||Registry file generated by the ESRI Compile and Register Add-In. You can double-click this
to register this component in the 'ESRI Mx Commands' category instead of using 'Add from file'.
||VB Project File for sample.
||Compiled project DLL.
ICommand, IApplication, IExtension, IExtensionConfig, IRgbColor, IColorBrowser, IColor