Command Using Persisted Settings

Created:4/27/2001
Last Modified:5/2/2001
Description:

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++):

  1. 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.
  2. Build this sample's DLL. This will also register the command in the appropriate component category.
  3. 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.
  4. 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):

  1. In ArcMap, open the Customize dialog. Click on 'Add from file' and select this sample's dll.
  2. 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.
  3. 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:

  1. 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.
  2. Add a new data frame by going to the 'Insert' menu. Notice that this dataframe has a background color too.
  3. Click on this command button to bring up a dialog which displays the current choice of active view, TOC view and map background color.
  4. Change these settings, and hit 'Save Settings'. You will notice that the changed settings have been applied to your document.
  5. Save your map document and close it. Open it again and notice the effects of your changes.
  6. Try doing the same with a map template.
  7. 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.

Application:
ArcMap

Difficulty: Intermediate


Visual Basic Visual C++
File Description
clsPersistCmd.cls Class file that implements the command.
frmPersistSettings.frm Form brought up by the command.
PersistSettings_CmdVB.RES Resource file for the bitmap used by the command.
PersistSettings_CmdVB.reg 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'.
PersistSettings_CmdVB.vbp VB Project File for sample.
PersistSettings_CmdVB.dll Compiled project DLL.


Key Interfaces: ICommand, IApplication, IExtension, IExtensionConfig, IRgbColor, IColorBrowser, IColor