Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Simple RTF based Help Dialog

0.00/5 (No votes)
3 Oct 2001 1  
Yet Another Simple Help Dialog

Sample Image - MyHelpDialog.jpg

Introduction

This Rich Text based Help Dialog is a quick and easy way of adding on-line help to your applications. For some applications its just too much work to build a complete help system, but its sufficient to display some guide lines. This dialog has the "looks and feel" of the real thing.

Features

  • Standard Help Window look and feel
  • Auto size of window to fit RTF text
  • Resizable
  • Auto scrollbars in case window is resized too small to fit complete RTF text
  • Copy and Print via context menu
  • Can load RTF from resource OR from file on disk

How to add this class to your project

The steps to include this dialog into your project are:

  1. Add the HelpDialog.cpp and HelpDialog.h files to your project
  2. Copy and Paste the following Help Dialog resources from the demo project resources into your project:
    • IDR_POPUP_HELP_MENU menu
    • IDD_HELP_DIALOG dialog
    • IDI_HELP_ICON icon
  3. Add a Help button or menu to your project (see sample project)

The Rich Text Format (RTF) contents of the help message can best be created using Wordpad. I have tried Word as well, but the resulting RTF format is sometimes too elaborate to be used in the Rich Edit control. You can tell if your RTF it too elaborate, because if that is the case the Help Dialog will not show any message at all ;-)

The RTF can be loaded in two different methods, the first is to import the RTF file into the resources of your project. The 2nd method is to load the RTF file from disk at runtime. Select the method that fits your needs best. The demo project shows both methods.

#include "HelpDialog.h"

//

// Example using the class from RTF resource

//

CSimpleHelpDemoDlg::OnHelpButton()
{
	CHelpDialog hlp(this, IDR_HELP); 	// create Help Dialog using RTF resource

	hlp.SetTitle( "Simple Help Demo" ); 	// set a title (optional)

	hlp.DoModal(); 			// pop it up

}

The next code show how to load the help message from a file on disk:

#include "HelpDialog.h"

//

// Example loading RTF from disk

//

CSimpleHelpDemoDlg::OnHelpButton()
{
	CHelpDialog hlp(this); 		// create Help Dialog

	hlp.SetTitle( "Simple Help Demo" ); 	// set a title (optional)

	hlp.LoadRTFFile( "Help2.rtf" );	// load the RTF from file

	hlp.DoModal(); 			// pop it up

}

The demo project also shows (see both Help menu items) how to use the dialog in modeless mode. Although a little bit more work is required, this is the preferred method. With a modeless help dialog, the user can switch to the application and refer to the help dialog at the same time. With the modal approach, as in the samples above, the help dialog must be closed first before the application window can be accessed.

Final notes

This article was inspired by the TCX Message Box By Thales P. Carvalho and in fact I used his dialog class at first for my help messages. Later I felt the need to make it look more like a real help message, hence this class. And yes, I know there's the real help system out there, but the steps involved in building a real help file (RTF file, Help ID's, Help Compiler, etc.) are sometimes simply too much work.

History

4 Oct 2001 - fix for the detected streamin bug.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here