/****************************************************************************** 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 // (Or WinUser ?) Definitions for HtmlHelp.h #include #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; }