You are here: Defining and Organizing Topics > Context Sensitive Help > Context-Sensitive Help in NetHelp

Context-Sensitive Help in NetHelp

NetHelp, the ComponentOne browser-independent help format, supports a versatile context-sensitive help facility that can be used virtually anywhere: on web pages, in web applications and in client applications on any platform written in any programming language. You can show NetHelp topics in a frame inside your application window or in a separate browser window. You also have control over what parts of the help system you want to expose to the user. You can show topic text without navigational frames, or you may want to include full NetHelp navigation with the Context, Index and Search tabs. NetHelp context-sensitive help uses the same context IDs assigned to topics in your project as do the HTML Help and WinHelp targets.

To call NetHelp from your application or web pages, use one of the D2H_ctxt.* source files provided with Doc-To-Help; they define the D2H_ShowHelp function needed to enable context-sensitive help.

Note: The D2H_ctxt.* files are installed in the C:\Program Files\ComponentOne\DocToHelp\Context-Sensitive Help folder by default. The location may be different if you installed Doc-To-Help somewhere else on your machine.

Unless you need to change the functionality, do not modify the D2H_ctxt.* file. Simply add it to your application or web pages as it is. It is necessary to call the D2H_ShowHelp function in all environments. This function is all you need to enable context-sensitive NetHelp. It is implemented in different programming languages for different environments:

Application

Language

File

Web applications and web pages

JavaScript

D2H_ctxt.js

Windows client applications

C#

D2H_ctxt.cs

VB.NET

D2H_ctxt.vb

Visual Basic 6.0

D2H_ctxt.bas

Java client applications

Java

D2H_ctxt.java

Samples demonstrating how to use context-sensitive help with NetHelp in each of these environments can be found in the C:\Program Files\ComponentOne\DocToHelp\Context-Sensitive Help\Samples directory. Please note that the location of this folder may be different if you installed Doc-To-Help somewhere else on your machine.

For each sample, start by opening the files below, then run the program, if necessary, and follow the instructions listed on the page:

CSharp

CSharp.csproj

Java

start_sample.bat

VB6

VB6.vbp

VB.NET

VB.NET.vbproj

WebPages

ctxt_sample.htm

If your programming language is not listed above, you can still use NetHelp context-sensitive help if you translate the code of the D2H_ShowHelp function to the language you are using.

The function is described below in more detail:

Function D2H_ShowHelp in JavaScript (web applications and web pages)

Syntax

function D2H_ShowHelp(contextID, mainURL, wndName, uCommand)

Parameters:

ContextID (integer number):

Context ID of the topic to display. See Context Sensitive Help for more information on assigning context IDs to topics.

mainURL (string):

URL of the main web page of the help. For example, the URL of a locally deployed NetHelp target can be a file path, although it still needs to be encoded as a URL with the prefix "file:///", such as file:///C:/Program Files/ComponentOne/DocToHelp/Samples/StyleGuide/NetHelp/default.htm; or, for a server-deployed NetHelp target it can be http://www.mycompany.com/myhelp/default.htm. This parameter is used to identify the help system containing the topic. It is necessary because you may use multiple help systems in the same application or even on the same web page.

wndName (string):

A frame or a browser window to display the topic in. Using this parameter you can show the topic in any frame or in a separate browser window. This parameter has the same possible values as the TARGET attribute of the A (anchor) tag in HTML. If you want to display help in a certain frame or in a separate browser window, set this parameter to that frame or window name. You can also use the standard names supported by the TARGET attribute of the A tag: _self, _blank, _parent, etc.

uCommand (integer number, one of the two possible values: 1 or 2):

This parameter specifies one of the two options (Note: you can use the symbolic names or the numbers 1,2):

CTXT_DISPLAY_FULLHELP (=1): Display the complete help system with Contents, Index and Search. The topic will be current in the Table of Contents, and the user will be able to navigate through the links in the topic and through the Context, Index and Search.

CTXT_DISPLAY_TOPICONLY (=2): Display the topic without the Contents, Index and Search. The user will still be able to navigate to other topics if this topic contains links to other topics, but the Contents, Index and Search will be hidden.

 

To enable the function:

Include the D2H_ctxt.js file with your web pages and add the following tag to the web pages where you want to use context-sensitive help:

<script language="JavaScript" src="D2H_ctxt.js">

</script>

Example:

<A HREF='JavaScript:D2H_ShowHelp(91, helpURL, "helpFrame",  CTXT_DISPLAY_TOPICONLY)'>Topic Only</A>

 

Function D2H_ShowHelp in Windows client applications

In Windows client applications, you can use NetHelp context-sensitive help in two different ways:

      Use the Microsoft WebBrowser control to show help inside one of your application windows. In this case you need to add a reference to the WebBrowser control to your application.

      Show help in a separate browser window. In this case you don’t need to use the WebBrowser control.

Syntax:

C#

D2H_ctxt.D2H_ShowHelp(int contextID, string mainURL, object wnd, Display uCommand)

Visual Basic .NET

D2H_ctxt.D2H_ShowHelp(ByVal contextID As Integer, ByVal mainURL As String, ByVal wnd As Object, ByVal uCommand As Display) As Boolean

Visual Basic 6.0

D2H_ShowHelp(ByVal ContextID As Integer, ByVal mainURL As String, ByVal wnd As Object, ByVal uCommand As Display) As Boolean

Parameters:

ContextID (integer number):

Context ID of the topic to display. See Context Sensitive Help for more information on assigning context IDs to topics.

mainURL (string):

URL of the main web page of the help. For example, the URL of a locally deployed NetHelp target can be a file path, although it still needs to be encoded as URL with the prefix "file:///", such as file:///C:/Program Files/ComponentOne/DocToHelp/Samples/StyleGuide/NetHelp/default.htm; or, for a server-deployed NetHelp target it can be http://www.mycompany.com/myhelp/default.htm. This parameter is used to identify the help system containing the topic. It is necessary because you may use multiple help systems in the same application.

wnd (WebBrowser object):

If this parameter is null (Nothing in Visual Basic .NET and Visual Basic 6.0), the help is shown in a separate browser window, as if you were opening an HTML file with a double-click. If this parameter is set to a WebBrowser component, the help is shown in that component. Using the WebBrowser component, you can show help inside your application windows.

uCommand (integer number, one of the two possible values: 1 or 2):

This parameter specifies one of the two options (Note: you can use the symbolic names or the numbers 1,2):

CTXT_DISPLAY_FULLHELP (=1): Display the complete help system with Contents, Index and Search. The topic will be current in the Table of Contents, and the user will be able to navigate through the links in the topic and through the Context, Index and Search.

CTXT_DISPLAY_TOPICONLY (=2): Display the topic without the Contents, Index and Search. The user will still be able to navigate to other topics if this topic contains links to other topics, but the Contents, Index and Search will be hidden.

 

To enable the function:

      Add one of the D2H_ctxt.* files to your project; use D2H_ctxt.cs for C#, D2H_ctxt.vb for Visual Basic .NET, or D2H_ctxt.bas for Visual Basic 6.0.

      To show context-sensitive help in one of your application windows, add the WebBrowser control reference to your application. If you choose to show help in a separate browser window, you don’t need a reference to the WebBrowser control.

Example:

C# and Visual Basic .NET

C1.D2H .D2H_ctxt.D2H_ShowHelp(91, helpURL, WebBrowser1,  CTXT_DISPLAY_TOPICONLY)

Visual Basic 6.0

D2H_ctxt.D2H_ShowHelp(91, helpURL, WebBrowser1,  CTXT_DISPLAY_TOPICONLY)

Function D2H_ShowHelp in Java client applications

In Java client applications (usually created with Swing components), the D2H_ShowHelp function uses JDIC (JDesktop Integration Components), in particular, the WebBrowser component. The WebBrowser class allows Java applications to use full browser HTML-rendering capabilities inside a Java component or in a separate browser window, just like the Microsoft WebBrowser control in Windows applications.

Syntax:

D2H_ctxt.D2H_ShowHelp(int contextID, String mainURL, WebBrowser wnd, int uCommand)

Note: D2H_ShowHelp is a method of the D2H_ctxt class

Parameters:

ContextID (integer number):

Context ID of the topic to display. See Context Sensitive Help for more information on assigning context IDs to topics.

mainURL (string):

URL of the main web page of the help. For example, the URL of a locally deployed NetHelp target can be a file path, although it still needs to be encoded as URL with the prefix "file:///", such as file:///C:/Program Files/ComponentOne/DocToHelp/Samples/StyleGuide/NetHelp/default.htm; or, for a server-deployed NetHelp it can be http://www.mycompany.com/myhelp/default.htm. This parameter is used to identify the help system containing the topic. It is necessary because you may use multiple help systems in the same application.

wnd (WebBrowser object):

If this parameter is null, the help is shown in a separate browser window (as if you were opening an HTML file with a double-click). If this parameter is set to a WebBrowser component, the help is shown in that component. Using the WebBrowser component, you can show help inside your application’s windows.

uCommand (integer number, one of the two possible values: 1 or 2):

This parameter specifies one of the two options (Note: you can use the symbolic names or the numbers 1,2):

CTXT_DISPLAY_FULLHELP (=1): Display the complete help system with the Contents, Index and Search. The topic will be current in the Table of Contents, and the user will be able to navigate through links in the topic and through the Context, Index and Search.

CTXT_DISPLAY_TOPICONLY (=2): Display the topic without the Contents, Index and Search. The user will still be able to navigate to other topics if this topic contains links to other topics, but the Contents, Index and Search will be hidden.

 

To enable the function:

To use D2H_ShowHelp in Java client applications, you need to install JDIC. JDIC is available at http://jdic.dev.java.net. You also need to add D2H_ctxt.java to your project’s source files. Building your application, add jdic.jar to your classpath. You can use the batch files in the sample directory located at C:\Program Files\ComponentOne\DocToHelp\Context-Sensitive Help\Samples\Java. Note that the location may be different if you installed Doc-To-Help somewhere else on your machine. In those batch files, change the values of the JDK_HOME and JDIC_HOME variables to point to your JDK and JDIC locations.

Without JDIC:

If you do not want to use JDIC, you can still show NetHelp context-sensitive help in Java client applications. Modify D2H_ctxt.java. excluding the parts using the WebBrowser component. Replace Desktop.browse(u) with a method you choose to open a URL in a browser. JDIC is required for showing help inside your application windows.

Example:

D2H_ctxt.D2H_ShowHelp(91, helpURL, browser, D2H_ctxt.CTXT_DISPLAY_TOPICONLY);