This document is archived and information here might be outdated.  Recommended version.


How to provide context-sensitive help for a custom command (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Building stand-alone applications > Using the Winforms ArcGIS Engine controls > Using the control commands > How to provide context-sensitive help for a custom command (ArcObjects .NET 10.6 SDK)

How to provide context-sensitive help for a custom command


Summary
This topic shows how to provide context-sensitive help to users of your custom command or tool. Users can read application-based help by clicking the custom commands with the ControlsContextHelpCommand What's This? tool.
This topic shows how to create a WinHelp (HLP) file, so your help will look and behave the same as the standard ArcGIS commands. You will set the custom command's HelpFile and HelpContextID properties so that the What's This? tool can map to the associated help stored in the help file.

In this topic


Creating the WinHelp file

To create the WinHelp file, perform the following steps:
  1. Compose the context-sensitive help in a rich text format (RTF) file including a topic ID in the #Footnote of the RTF file (for example, #MyFullExtent_Command).
  2. Create a help project (HPJ) file using a free downloadable product, such as Microsoft Help Workshop, and add the RTF file to the project.
  3. Determine a numeric help ID (for example, 1234) that you can use in your custom command to link to the topic ID specified in the RTF footer. You can use Microsoft Help Workshop to add this numeric value by opening the .hpj file, clicking Map, then clicking Add (to add the mapping for an individual topic).
  4. In Microsoft Help Workshop, compile the .hpj file to create the WinHelp file; for example, MyHelpFile.hlp.

Setting custom command properties

In the command constructor of a command or tool that implements BaseCommand or ICommand, assign the help ID and the help file name as shown in the following code example:
[C#]
public MyCommand()
{
    ... base.m_helpFile="MyHelpFile.hlp";
    //The Context Help ID as defined when compiling the RTF file into the HelpFile.
    base.m_helpID=1234;
    ...
}
[VB.NET]
Public Sub New()
    MyBase.New()
    ...
    MyBase.m_helpFile="MyHelpFile.hlp"
    'The Context Help ID as defined when compiling the RTF file into the HelpFile.
    MyBase.m_helpID=1234
    ...
End Sub
Upon deployment of the HLP file, you must register its name (for example, MyHelpFile.hlp) as a new string value in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Help or provide the full path name to the m_helpFile property previously described.

Using the custom command and viewing the context-sensitive help

To use the custom command and view the context-sensitive help, perform the following steps:
  1. Run an application that loads your custom command and the context-sensitive help command onto a ToolbarControl. The following code example shows how to load these two commands:
[C#]
//Add the custom command to the ToolbarControl.
axToolbarControl1.AddItem("CSharpMyFullExtent.MyCommand", 0,  - 1, true, 0,
    esriCommandStyles.esriCommandStyleIconOnly);
//Add the Context Help command (named What's This?) to the ToolbarControl.
axToolbarControl1.AddItem("esriControls.ControlsContextHelpCommand", 0,  - 1, false,
    0, esriCommandStyles.esriCommandStyleIconOnly);
[VB.NET]
'Add the custom command to the ToolbarControl.
AxToolbarControl1.AddItem("VBDotNETMyFullExtent.MyCommand", 0, -1, True, 0, esriCommandStyles.esriCommandStyleIconOnly)
'Add the Context Help command (named What's This?) to the ToolbarControl.
AxToolbarControl1.AddItem("esriControls.ControlsContextHelpCommand", 0, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
  1. Use the What's This tool to click the custom command. The context-sensitive help opens.


See Also:

BaseCommand




Additional Requirements
  • Microsoft Help Workshop (a free download) or another product to create an HPJ file
  • Windows Help program (WinHlp32.exe) to view context-sensitive help using Windows Vista and Windows 7 and above

Development licensing Deployment licensing
Engine Developer Kit Engine
ArcGIS for Desktop Basic
ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced