Skip to content

Adding Help to Your Windows Applications

This topic will show you how to add Compiled HTML Help to your DataFlex Windows projects, and link to specific pages (topics) and bookmarks in a Compiled HTML project. This allows you to create help for the users of your projects, including context-sensitive links from individual views or objects in your project.

Compiled HTML Help

Compiled HTML Help has replaced WinHelp as the standard help format for Windows-based software projects. Compiled HTML Help files are created by compiling standard HTML pages into .CHM files, which creates the type of help like the DataFlex help that you are reading now, including (usually) a pane on the left-hand side with a Table of Contents, Index, and text search capabilities.

Important!

This section requires that the "My First Windows Application" Windows project and the "Hello World" view were created in the QuickStart workspace.

If this is not the case, switch to the Creating Your First Windows Application step now and return here when you have completed it.

Creating Compiled HTML Help

There are many products available, including some free ones, that allow you to edit and compile Compiled HTML Help projects. You can find detailed documentation about Compiled HTML Help in the Microsoft Developer documentation (MSDN) under "HTML Help". The DataFlex help you are currently reading is created using RoboHelp, with the exception of the Class Reference, which is created dynamically from source code comments in the DataFlex packages and compiled using the Microsoft HTML Help Workshop compiler.

The basic concept is that you have numerous individual HTML pages that are added to "books" and then compiled. A single HTML page (such as this one) is referred to as a topic. You can link to any topic directly from a DataFlex Windows project, so that the user can access it by pressing the help button on the keyboard (F1).

Just as in HTML pages that are viewed in web browsers, you can have bookmarks in Compiled HTML Help files that refer to specific places on a page. This is useful if you have very long HTML pages and want users to be able to get to a specific spot on the page. You can also link to any bookmark on a page (topic) directly from a DataFlex Windows project, so that the user can access it by pressing the help button on the keyboard (F1).

Adding HTML Help to an Application

Once you have a compiled .CHM project, it is very simple to integrate links to it into a Windows project.

  1. If not already open, open the DataFlex Studio and open the QuickStart workspace.
  2. Make sure that MyFirstWindowsApplication.src is the Current Project selected in Workspace Explorer.
  3. Open the MyFirstWindowsApplication.src file. You can do so by double-clicking on the file in Workspace Explorer or right-clicking on it and selecting Open.
  4. Select the oApplication object in Code Explorer. In the Properties window, set the psHelpFile property to MyFirstWindowsApplication.chm. MyFirstWindowsApplication.chm is a Compiled HTML help file that was created for use with this application in the QuickStart workspace. It will allow you to see how to connect to a Compiled HTML help file.
  5. Click on the Run button on the Studio's toolbar.

Your application will run. Once the application is on the screen, press F1. You will see the "My First Windows Application" help file appear.

As you can see, your Windows application is now connected to a Compiled HTML help file. Since we have not specified any context-sensitive connections yet, the application opened with the default page (in this case, the "My First Windows Application" page).

Close the help file and the "My First Windows Application" program.

  1. Open the "Hello World" view in the Studio. Click on the + in the tree view to expand MyFirstWindowsApplication.src, then click on the + to expand Views. Double-click on HelloWorld.vw in Workspace Explorer or right-click on it and select Open.
  2. Select the oHelloWorld view object in Code Explorer. In the Properties window, change the value of psHtmlHelpTopic to Hello_World.htm.

psHtmlHelpTopic Property

The psHtmlHelpTopic property should be set to the name of an actual HTML page that is part of your Compiled HTML Help project. This allows you to use sensible names for your help pages, such as the names of views and dialogs in your application. This makes maintenance of your help projects alongside your applications much simpler.

In this sample, the psHtmlHelpTopic property is set only at the view level, and all objects in the view find the same page via delegation. You can, however, set this property in any object and thus make your application help as granular or general as is needed for your application.

  1. Click on the Compile Project, then the Run toolbar button. When the application runs, click on the View menu and then Hello World to open the view. Once the view is open, press F1.

You will see the "My First Windows Application" help file appear, but this time, the "Hello World" page is displayed instead of the default page.

Close the help file and the "My First Windows Application" program.

  1. Change the psHtmlHelpTopic property of the oHelloWorld view object to Hello_World.htm#TestBookmark.
  2. Click on the Run button on the Studio's toolbar. When the application runs, click on the View menu and then Hello World to open the view. Once the view is open, press F1.

Once again, you will see the "My First Windows Application" help file appear. This time, the "Hello World" page is displayed, but it is scrolled all the way to the bottom of the page, where the Hello_World.htm page contains a bookmark named TestBookmark.

Adding Help Buttons to an Application

You may want to add "help buttons" to various objects in your project, so that users can click a button to get help instead of, or in addition to, pressing F1.

  1. Drag and drop a Button control from the Base Controls group on the Class Palette onto the oHelloWorld view.
  2. Click on the Properties toolbar button to open the Properties window.

  1. Change the Label property of the button control to Help in the Properties window.
  2. Double-click on the button control in Code Explorer to display the code for the button object.
  3. Add the following line of code to Procedure OnClick:
Send Help of oHelloWorld

The completed code should look like this:

The code fires the Help method, which is the standard help message, of the oHelloWorld view object. This way, the program will see what context-sensitive help page is defined for the view object and open it. Depending on what you want to display help for, you can send the Help message to the desired object.

  1. Click on the Run button on the Studio's toolbar. When the application runs, click on the View menu and then Hello World to open the view. Once the view is open, click on the Help button.

You will see the "My First Windows Application" help file appear and the text for the TestBookmark on the "Hello World" page displayed. This result is identical to pressing F1 anywhere in the "Hello World" view.