Use htmlhelp (.chm) help file in VC

zhaozj2021-02-17  69

After I call HTML HELP with VC, I found that HTML Help with VC is not a simple matter.

The HTML HELP is called in Visual C 6 without the ready-made functions, and the HTMLHELP () API function is required. Before calling this function, you need to add HTMLHELP libraries and header files in your project:

1. Specify the path to htmlhelp.h. Select menu "Project -> Settings ..." to open the "Project Settings" dialog. Select the "C / C " tab, select the contents of the "Category" list box to "preproces", fill in the path containing "htmlp.h" file in the "Additional Include Director" item. You can find it on your hard drive if you have "HTML Help Workshop", then there is a "incrude" directory in the "HTML Help Workshop" program.

2. Specify the path to htmlhelp.lib. According to a similar method, select the "LINK" tab, select "Category" to "Input", and fill in the "HTMLHELP.LIB" file in "Additional Library Path". Similarly, the "lib" directory in the "HTML Help Workshop" program directory is.

3. Specify the lib file. Also in the "LINK" tab, select "Category" to "General", fill in "Htmlhelp.lib" in "Object / Librarie Module".

4. Finally, htmlhelp.h is included in the program. You can choose a suitable location to join "#include", but I suggest you add this sentence to "stdafx.h".

Note: All of the above includes this topic in the "Including" topic "Includlication" topic in MSDN, and enter the lookup content in the Search tab to find the topic.

Finally, everyone is concerned about, how to call HTML HELP in the program.

As with HTML HELP in Visual Basic 6, you first need to locate the location of the help file. If we put the help file (.chm) in the program path, how should we get the program path? The API function getModuleFileName (), for example, I use the following code positioning program path and the full path file name of the file:

Cstring apppath;

GetModuleFileName (null, apppath.getBuffer); MAX_PATH);

// Note: Use the API function to get the full path file name of the program file, and it is the path after removing the file name.

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) via HTMLHELP is as follows:

HTMLHELP (NULL, (LPCSTR) helpfile, hh_display_topic, 0); // directly open the default topic of the help file.

or

HTMLHELP (NULL, (LPCSTR) HelpFile, HH_HELP_CONText, 1);

// Open one of the topics to implement the context-related help calls.

In this way, in Visual C 6, you can call HTMLHELP. This time, the API function is used, that is, it can be used to change you ... - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -

//

__________ / lb / ___ Outinn

/ _ [] _ ​​/ ____ / /

/ _________ / | () | / __ /

Http://outinn.yeah.net/

| ____ / - | __ | - / | Welcome to Visit Outinn!

| __ | == | ___ | || | __ |

- = - = - = - | _ || _ | = - FANCY,

Outinn@china.com

转载请注明原文地址:https://www.9cbs.com/read-31331.html

New Post(0)