In VC, the CHM File is called mainly by using the htmlhelp function in the HTML Help Workshop SDK. If HTML Help Workshop is not installed, download it from the Microsoft Website:
Http://msdn.microsoft.com/library/en-us/htmlhelp/html/hwMicrosoftHTMLHelpDownloads.asp Description of the htmlhelp () function in the HTML Help api reference is as follows:
Hwnd htmlhelp ( Hwnd hwndcaller, Lpcstr pszfile, Uint ucommand, DWORD dwdata ); Parameter/Description Hwndcaller Specifies the form handle that calls htmlhelp. The help form belongs to the form. When the help form is closed, htmlhelp () returns the focus to the form to which it belongs, except when the form is desktop. If hwndcaller is a desktop, the operating system determines where the focus is returned. In addition, if htmlhelp () sends any notification messages from the help form, these messages will also be sent to hwndcaller, this is like activating the notification message tracking mechanism defined in the help form. Pszfile The pszfile parameter depends on ucommand execution ). You can also add a greater than sign (>) to the front to specify a form type name. If the specified command does not request a file, the parameter value can be null. Ucommand Specify the completed command. Dwdata Specify any data that may be requiredUcommandThe parameter value is based on.
Return Value Based on the value specified by ucommand and its impact, htmlhelp () returns one or two of the following values: 1. Handle of the help form. 2. null. In some cases, null indicates failure. In addition, null indicates that the help form is not created. To successfully call the CHM file, you must add htmlhelp. h and htmlhelp. lib to the project in the VC development environment. The specific steps are as follows:
Project-> Settings (Alt + F7 ).
1. Select Preprocessor from the category list on the C/C ++ tab, and fill in the htmlhelp. h address in the additional include directories box (for example:
C:/program files/HTML Help Workshop/include/htmlhelp. h ). 2. Select input from the gategory list on the Link tab, and enter the htmlhelp. Lib address (for example, C:/program files/html) in the additional library path box. Help Workshop/lib/htmlhelp. Lib ). 3. Select general from the gategory list on the Link tab, and fill in htmlhelp. Lib in the object/library modules box. Assume that the CHM application to be called is an SDI Program, and the compiled help file and program are in the same directory. (In the sample code, the CHM File Name Is help. CHM, and getmodulefilename is used to obtain the Help file path .) 1. Add htmlhelp. h to stdafx. h:# Include "htmlhelp. H". 2. Call CHM:
Char szfilepath [max_path], szpath [max_path]; Getmodulefilename (null, szfilepath, max_path); // obtain the current program directory Size_t IPOs = strlen (szfilepath)-strlen (strrchr (szfilepath ,'//')); Strncpy (szpath, szfilepath, IPOs ); Strcat (szpath, "// help. chm "); Htmlhelp (null, szpath, hh_display_topic, null );
For more information about htmlhelp functions, refer to the HTML Help api reference.
|