找到这个资料,希望对你有用
The new HtmlHelp system is a great way to write you online documentation if you
already know HTML. But then, how do you call it from your application ?
I hacked this short module for LabWindows in order to display contextual help,
the ChmHelp() function is similar to the SystemHelp() function and if defined
in HtmlHelp.h. Note, you need to include HtmlHelp.lib and Advapi32.lib to you
project. You need the Microsoft HtmlHelp workshop in order to get those
libraries (and to compile chm files).
Two source files: ChmHelp.h and ChmHelp.c.
Category: Windows 95 + IE4, sample C source code
//head file
#ifndef _CHM_HELP
#define _CHM_HELP
#include < HtmlHelp.h>
extern int ChmHelp(const char* Context);
extern void QuitChmHelp(void);
#endif
//.c
/******************************************************************************
MODULE: CHM_HELP.C
PURPOSE: Gives context sensitive help using HtmlHelp CHM files
To display a particular topic, call the ChmHelp function of this module
with the name of the html file to display
Help("Topic.html");
For more help on building help files for Windows98, see:
http://msdn.microsoft.com/msdn-online/workshop/author/htmlhelp/
download and install the HtmlHelp Workshop.
IMPORTANT: the file HelpFile.chm must be in the same directory than the program
NOTE: context sensitive help using constant numbers does not work
******************************************************************************/
#include <Windows.h> // (Or WinUser ?) Definitions for HtmlHelp.h
#include <userint.h>
#include "ChmHelp.h"
static char HelpFile[MAX_PATHNAME_LEN];
static BOOL MainHelpWindowIsOpen=FALSE;
static int WH=-1;
static int CallbackID=0;
static int WinMsgNum;
static char* ChmFile="HelpFile.chm";
// When is this called ?!?
static void HelpCallback(unsigned int wParam, unsigned lParam, void *callbackData) {
Breakpoint();
}
/******************************************************************************
FUNCTION: ChmHelp
PURPOSE: Launch the Windows help with the appropriate context file
IN: Context: name of the html file part of the chm file to display
RETURN: FALSE on failure
******************************************************************************/
int ChmHelp(const char* Context) {
HWND Ret;
char File[MAX_PATHNAME_LEN];
if (!MainHelpWindowIsOpen) {
if (GetFullPathFromProject (ChmFile, HelpFile)==-1) {
MessagePopup("Error !", "Unable to find file HelpFile.CHM in current directory.");
return FALSE;
}
//if (Command==HELP_CONTEXTPOPUP) Command=HH_HELP_CONTEXT;
WH=GetCVIWindowHandle ();
WinMsgNum = RegisterWinMsgCallback (HelpCallback, NULL, 0, 0, &CallbackID, 1);
MainHelpWindowIsOpen=TRUE;
}
strcpy(File, "mk
MSITStore:"); // ??? Buggy without it
strcat(File, HelpFile);
strcat(File, "::/");
strcat(File, Context);
Ret=HtmlHelp((HWND)WH, /*Help*/File, HH_DISPLAY_TOPIC, 0/*(DWORD)File*/);
return TRUE;
}
/******************************************************************************
FUNCTION: QuitHelp
PURPOSE: Should be called when quitting the main program. This will close the CHM window
******************************************************************************/
void QuitChmHelp(void) {
HtmlHelp((HWND)WH, HelpFile, HH_CLOSE_ALL, 0); // Closing the Help window
if (CallbackID!=0) UnRegisterWinMsgCallback(CallbackID);
//SystemHelp (HelpFile, HELP_QUIT, 0, 0);
MainHelpWindowIsOpen=FALSE;
WH=-1;
}