## wxHtmlHelpController

This help controller provides an easy way of displaying HTML help in your application (see test sample). The help system is based on books (see AddBook). A book is a logical section of documentation (for example "User's Guide" or "Programmer's Guide" or "C++ Reference" or "wxWidgets Reference"). The help controller can handle as many books as you want.

Although this class has an API compatible with other wxWidgets help controllers as documented by wxHelpController, it is recommended that you use the enhanced capabilities of wxHtmlHelpController's API.

wxHTML uses Microsoft's HTML Help Workshop project files (.hhp, .hhk, .hhc) as its native format. The file format is described here. Have a look at docs/html/ directory where sample project files are stored.

You can use Tex2RTF to produce these files when generating HTML, if you set htmlWorkshopFiles to true in your tex2rtf.ini file. The commercial tool HelpBlocks (www.helpblocks.com) can also create these files.

Note

It is strongly recommended to use preprocessed .hhp.cached version of projects. It can be either created on-the-fly (see SetTempDir) or you can use hhp2cached utility from utils/hhp2cached to create it and distribute the cached version together with helpfiles. See samples/html/help sample for demonstration of its use.

See also

Information about wxBestHelpController, wxHtmlHelpFrame, wxHtmlHelpDialog, wxHtmlHelpWindow, wxHtmlModalHelp

Derived from

wxHelpControllerBase

Include files

<wx/html/helpctrl.h>

Members

wxHtmlHelpController::wxHtmlHelpController
wxHtmlHelpController::AddBook
wxHtmlHelpController::CreateHelpDialog
wxHtmlHelpController::CreateHelpFrame
wxHtmlHelpController::Display
wxHtmlHelpController::DisplayContents
wxHtmlHelpController::DisplayIndex
wxHtmlHelpController::KeywordSearch
wxHtmlHelpController::ReadCustomization
wxHtmlHelpController::SetTempDir
wxHtmlHelpController::SetTitleFormat
wxHtmlHelpController::UseConfig
wxHtmlHelpController::WriteCustomization

### wxHtmlHelpController::wxHtmlHelpController

wxHtmlHelpController(int style = wxHF_DEFAULT_STYLE, wxWindow* parentWindow = NULL)

Constructor.

Parameters

style is a combination of these flags:

wxHF_TOOLBAR | The help window has a toolbar.
wxHF_FLAT_TOOLBAR | The help window has a toolbar with flat buttons (aka coolbar).
wxHF_CONTENTS | The help window has a contents panel.
wxHF_INDEX | The help window has an index panel.
wxHF_SEARCH | The help window has a search panel.
wxHF_BOOKMARKS | The help window has bookmarks controls.
wxHF_OPEN_FILES | Allows user to open arbitrary HTML document.
wxHF_PRINT | The toolbar contains "print" button.
wxHF_MERGE_BOOKS | The contents pane does not show book nodes. All books are merged together and appear as single book to the user.
wxHF_ICONS_BOOK | All nodes in contents pane have a book icon. This is how Microsoft's HTML help viewer behaves.
wxHF_ICONS_FOLDER | Book nodes in contents pane have a book icon, book's sections have a folder icon. This is the default.
wxHF_ICONS_BOOK_CHAPTER | Both book nodes and nodes of top-level sections of a book (i.e. chapters) have a book icon, all other sections (sections, subsections, ...) have a folder icon.
wxHF_EMBEDDED | Specifies that the help controller controls an embedded window of class wxHtmlHelpWindow that should not be destroyed when the controller is destroyed.
wxHF_DIALOG | Specifies that the help controller should create a dialog containing the help window.
wxHF_FRAME | Specifies that the help controller should create a frame containing the help window. This is the default if neither wxHF_DIALOG nor wxHF_EMBEDDED is specified.
wxHF_MODAL | Specifies that the help controller should create a modal dialog containing the help window (used with the wxHF_DIALOG style).
wxHF_DEFAULT_STYLE | `wxHF_TOOLBAR | wxHF_CONTENTS | wxHF_INDEX | wxHF_SEARCH | wxHF_BOOKMARKS | wxHF_PRINT`

parentWindow is an optional window to be used as the parent for the help window.

### wxHtmlHelpController::AddBook

bool AddBook(const wxFileName& bookFile, bool showWaitMsg)

bool AddBook(const wxString& bookUrl, bool showWaitMsg)

Adds book (.hhp file - HTML Help Workshop project file) into the list of loaded books. This must be called at least once before displaying any help.

bookFile or bookUrl may be either .hhp file or ZIP archive that contains arbitrary number of .hhp files in top-level directory. This ZIP archive must have .zip or .htb extension (the latter stands for "HTML book"). In other words, `AddBook(wxFileName("help.zip"))` is possible and is the recommended way.

Parameters

showWaitMsg

If true then a decoration-less window with progress message is displayed.

bookFile

Help book filename. It is recommended to use this prototype instead of the one taking URL, because it is less error-prone.

bookUrl

Help book URL (note that syntax of filename and URL is different on most platforms)

Note

Don't forget to install the archive wxFileSystem handler with `wxFileSystem::AddHandler(new wxArchiveFSHandler);` before calling this method on a .zip or .htb file!

### wxHtmlHelpController::CreateHelpDialog

virtual wxHtmlHelpDialog* CreateHelpDialog(wxHtmlHelpData * data)

This protected virtual method may be overridden so that when specifying the wxHF_DIALOG style, the controller uses a different dialog.

### wxHtmlHelpController::CreateHelpFrame

virtual wxHtmlHelpFrame* CreateHelpFrame(wxHtmlHelpData * data)

This protected virtual method may be overridden so that the controller uses a different frame.

### wxHtmlHelpController::Display

void Display(const wxString& x)

Displays page x. This is THE important function - it is used to display the help in application.

You can specify the page in many ways:

- as direct filename of HTML document
- as chapter name (from contents) or as a book name
- as some word from index
- even as any word (will be searched)

Looking for the page runs in these steps:

1. try to locate file named x (if x is for example "doc/howto.htm")
2. try to open starting page of book named x
3. try to find x in contents (if x is for example "How To ...")
4. try to find x in index (if x is for example "How To ...")
5. switch to Search panel and start searching

void Display(const int id)

This alternative form is used to search help contents by numeric IDs.

wxPython note: The second form of this method is named DisplayId in wxPython.

### wxHtmlHelpController::DisplayContents

void DisplayContents()

Displays help window and focuses contents panel.

### wxHtmlHelpController::DisplayIndex

void DisplayIndex()

Displays help window and focuses index panel.

### wxHtmlHelpController::KeywordSearch

bool KeywordSearch(const wxString& keyword, wxHelpSearchMode mode = wxHELP_SEARCH_ALL)

Displays help window, focuses search panel and starts searching. Returns true if the keyword was found. Optionally it searches through the index (mode = wxHELP_SEARCH_INDEX), default the content (mode = wxHELP_SEARCH_ALL).

Important: KeywordSearch searches only pages listed in .hhc file(s). You should list all pages in the contents file.

### wxHtmlHelpController::ReadCustomization

void ReadCustomization(wxConfigBase* cfg, wxString path = wxEmptyString)

Reads the controller's setting (position of window, etc.)

### wxHtmlHelpController::SetTempDir

void SetTempDir(const wxString& path)

Sets the path for storing temporary files - cached binary versions of index and contents files. These binary forms are much faster to read. Default value is empty string (empty string means that no cached data are stored). Note that these files are not deleted when program exits.

Once created these cached files will be used in all subsequent executions of your application. If cached files become older than corresponding .hhp file (e.g. if you regenerate documentation) it will be refreshed.

### wxHtmlHelpController::SetTitleFormat

void SetTitleFormat(const wxString& format)

Sets format of title of the frame. Must contain exactly one "%s" (for title of displayed HTML page).

### wxHtmlHelpController::UseConfig

void UseConfig(wxConfigBase* config, const wxString& rootpath = wxEmptyString)

Associates config object with the controller.

If there is associated config object, wxHtmlHelpController automatically reads and writes settings (including wxHtmlWindow's settings) when needed.

The only thing you must do is create wxConfig object and call UseConfig.

If you do not use UseConfig, wxHtmlHelpController will use default wxConfig object if available (for details see wxConfigBase::Get and wxConfigBase::Set).

### wxHtmlHelpController::WriteCustomization

void WriteCustomization(wxConfigBase* cfg, wxString path = wxEmptyString)

Stores controllers setting (position of window etc.)