Use the htmlhelp (. CHM) Help File in VC

Source: Internet
Author: User

After using VC to call HTML Help, I found that using VC to call HTML help is not a simple task.

There is no ready-made function for calling HTML Help in Visual C ++ 6. You need to call the htmlhelp () API function. Before calling this function, you must add the library and header file of htmlhelp to your project:

1. Specify the path of htmlhelp. h. Select "Project-> Settings..." to open the "Project Settings" dialog box. Select the "C/C ++" tab, select "preprocesor" in the "category" list box, and enter "htmlhelp" in the "Additional include directories" item. h. You can find this file on your hard disk. If you have installed "HTML Help Workshop"ProgramThere is an "include" directory under the directory.

2. Specify the path of htmlhelp. Lib. Select the "Link" tab, set "category" to "input", and enter the path containing the "htmlhelp. lib" file in "additional library path" as follows. Similarly, the "lib" directory under the "HTML Help Workshop" program directory is.

3. Specify the Lib file. Similarly, on the "Link" tab, select "category" as "general" and fill in "htmlhelp. lib" in "Object/librarie module ".

4. Finally, include htmlhelp. h In the program. You can add "# include" to a proper position, but I suggest you add this sentence to "stdafx. H.

Note: All the above content is described in the "including HTML help support files in an application" topic of msdn, on the "Search" tab, enter "htmlhelp" to find the topic.

Finally, we are all concerned about how to call HTML Help in a program.

Just like using HTML Help in Visual Basic 6, you must first locate the location of the Help file. If we put the Help file (. CHM) in the program path, how can we get the program path? The API function getmodulefilename () is used in the Program Base Camp. For example, I use the followingCodeLocate the program path and obtain the complete file path File Name:

Cstring apppath;

Getmodulefilename (null, apppath. getbuffer (max_path), max_path );

// Note: this API function is used to obtain the complete path file name of the program file. After removing the file name, it is the path.

Apppath. releasebuffer ();
Int n = apppath. reversefind ('/');
Cstring helpfile;
Helpfile = apppath. Left (N );
Tchar c = helpfile. getat (n-1 );
If (C = '/')
Helpfile + = "htmlhelp. chm ";
Else
Helpfile + ="/Htmlhelp. CHM";

The program code for calling the Help file (. CHM) through htmlhelp is as follows:

Htmlhelp (null, (lpcstr) helpfile, hh_display_topic, 0 );

// Open the default topic of the Help file directly.

Or

Htmlhelp (null, (lpcstr) helpfile, hh_help_context, 1 );

// Open a topic to call context-related help.

In this way, you can also call htmlhelp in Visual C ++ 6. This time, the API function is used. That is to say, you can use it with a slight change ......

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.