How to create a tri-pane HTML Help window with Win32 SDK programming

Source: Internet
Author: User
Tags win32 knowledge base

HTML help enables users to use a tool bar, view directories, and help topics in one of the helping Windows. Currently, there are two ways to create a tri-pane type of HTML Help window:

Create a window using HTML help Workshop

Using the HTML help API to programmatically create a window

This article describes how to create a tri-pane HTML Help window using both of these methods.

Use a predefined window

It is easy to create and modify a project's window definition in an HTML Help Workshop environment, for additional information about window definitions, refer to Microsoft Knowledge Base article: Q189084 howto:create a tri-pane window with HTML help works Hop

This article assumes that in your application development tool for Visual C + +, you have to use HTML Help in your own program, and you must rely on the API functions provided by HTML Help; To invoke these API functions, you must include the Htmlhelp.h file and hhct the library file Rl.lib or Htmlhelp.lib are linked to their own program code. As soon as you install the HTML Help Workshop environment, these files are stored in the Include and Lib directories under HTML Help Workshop.

In the following demo code, Sample.chm is a compiled HTML Help file with a window definition called "Mywindow," which demonstrates how to invoke the HTML Help API function in an MFC program:

CMainFrame Message Handler

void Cmainframe::onhelp ()

{

Display the topic "intro.htm" in the window defined

In the HTML help Workshop

HtmlHelp (M_hwnd, "Sample.chm::intro.htm>mywindow"),

hh_display_topic,0);

}

Using the HTML help API

In order to create a three-pane window, you must first create and fill in the Hh_wintype structure. The HH_WINTYPE structure is defined in HtmlHelp.h and is described in detail in the HTML Help Workshop documentation. Here is an example:

Sample Code

///////////////////////////////////////////

Create an HH_WINTYPE structure.

{

Hh_wintype M_hhwintype;

Initialize all structure to zero.

ZeroMemory (&m_hhwintype, sizeof (Hh_wintype));

Define a custom message for use with idnotify.

are responsible for ensuring the This ID

Does not conflict with the other WINDOWS/MFC messages.

#define IDD_HELPTAB 69999

Set the size of the structure.

m_hhwintype.cbstruct = sizeof (Hh_wintype);

Set up the properties of the HTML window:

Tripane window, sync topic with INDEX/TOC, and so forth.

Note:fsvalidmembers-hhwin_param_properties must be set.

M_hhwintype.fswinproperties = Hhwin_prop_tri_pane |

Hhwin_prop_auto_sync;

Put back, home, FORWARD, and EXPAND buttons on toolbar pane.

Note:fsvalidmembers-hhwin_param_tb_flags must be set.

M_hhwintype.fstoolbarflags = Hhwin_button_back |

Hhwin_button_home | Hhwin_button_forward |

Hhwin_button_expand;

The file is in the right pane. The full path isn't needed.

M_hhwintype.pszfile = "intro.htm";

Full Paths or CHM locations of various files (if used).

To specify that's a file is within a CHM and use the following

Syntax: "Chmfilename.chm::filename.xxx"

Home Page:

M_hhwintype.pszhome = "c:mypathintro.htm";

Table of Contents:

M_hhwintype.psztoc = "C:MYPATHCONTENTS.HHC";

Index:

M_hhwintype.pszindex = "C:MYPATHINDEX.HHK";

Expansion width of navigation Pane (left pane):

Note:fsvalidmembers-hhwin_param_nav_width must be set.

M_hhwintype.inavwidth = 175;

Initial Display State:

Note:fsvalidmembers-hhwin_param_showstate must be set.

M_hhwintype.nshowstate = Sw_restore;

TOC should be activated.

Note:fsvalidmembers-hhwin Param_cur_tab must is set.

M_hhwintype.curnavtype = Hhwin_navtype_toc;

Tabs on top.

Note:fsvalidmembers-hhwin_param_tabpos must be set.

M_hhwintype.tabpos = Hhwin_navtab_top;

ID to use in WPARAM in wm_notify:

M_hhwintype.idnotify = Idd_helptab;

Title of Help Window:

M_hhwintype.pszcaption= "My Title";

Indicate which fields in structure are valid.

M_hhwintype.fsvalidmembers = Hhwin_param_styles |

hhwin_param_properties | Hhwin_param_rect |

Hhwin_param_tb_flags | Hhwin_param_nav_width |

Hhwin_param_showstate | Hhwin_param_tabpos |

Hhwin_param_cur_tab;

Specify the name of the window definition.

M_hhwintype.psztype = "Mywindowname";

This is the call creates the new type from the values in

The HH_WINTYPE structure. This is example assumes that

A valid CHM file, "Sample.chm", exists.

HtmlHelp (M_hwnd, "C:mypathsample.chm"),

Hh_set_win_type, (DWORD) &m_hhwintype);

}

Display the default topic in the window this is defined above

MFC ' s CFRAMEWND::ONHELP message handler.

void Cmainframe::onhelp ()

{

HtmlHelp (M_hwnd, "Sample.chm>mywindowname"),

hh_display_topic,0);

}

Finally, I want to highlight a few things to note when using the HTML help API in Visual C + + engineering:

First, include "Htmlhelp.h" in the. cpp source file that invokes the HTML help API. After the HTML Help Workshop is installed, the file "Htmlhelp.h" is stored in the Include subdirectory under the HTML Help Workshop directory.

Second, in the VC project to add Htmlhelp.lib file, in order to ensure that the compiler link when the API successfully output. After the HTML Help Workshop is installed, the file "Htmlhelp.lib" is stored in the LIB subdirectory of the HTML Help Workshop directory.

Third, when building VC project, may produce the following warning information (how to use Hhctrl.lib library file, this problem does not exist.) ):

... default lib LIBCMT conflicts with the use of the other libs; Use/nodefaultlib:library.

If so, you can set the VC's compilation Environment by:

On the Project menu, select Settings-> link label-> Category drop-down list-> Select Input, and then enter Ignore in the Libraries LIBCMT edit box. This masks the default library search (Disable), so if you use the default library, you must explicitly list it.

The above steps should enable the Visual C + + project to successfully invoke the HTML help API.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.