简体   繁体   中英

How to upgrade from ::WinHelp to CHM?

I have a large legacy project in C++. It still nicely compiles with Borland C++ 5.02 with no problem, except for one: the help system does not work. Internally, it calls the API functions

::WinHelp(0, GetHelpFile().c_str(), HELP_CONTEXT, helpFileContextId);
::WinHelp(0, GetHelpFile().c_str(), HELP_QUIT, 0);

and then seemingly relies on Windows to manage the help system. Naturally, with Windows 10 it does not work.

I have successfully converted the HLP file into the CHM format. The new .CHM file opens OK when I click on it.

The question is: Is there a simple way to switch the legacy code to the .CHM file without much rewriting?

I understand that I can replace all occurrences of ::WinHelp to ::HtmlHelp, but this seems to be much rewriting. Is there a simpler way?

If you really managed to turn the old WinHelp file including the context-sensitive help into a CHM, most of the work is already done.

I am not a C++ programmer - working more in help authoring and other programming languages eg Visual Basic (.net). But, I rember some old stuff ...

You'll find a tutorial connecting HTMLHelp on Windows at User Assistance for your programs .

  • Please look at the first section of Topics entitled "Connecting Help to Your Programs".
  • The tutorial (PDF) is entitled "Connecting HTML Help to C++/MFC Programs".

Please note, I didn't try this but would like to pass it on as an idea for your needs. Search for "Override the Default Context Help Behavior" and check the code section for your requirements

In the Main Frame class, create a WinHelp function (yes, WinHelp, not HtmlHelp) using the Class Wizard:

void CMainFrame::WinHelp(DWORD dwData, UINT nCmd)
{
CWinApp* theApp = AfxGetApp();
CString helpFilePath = theApp->m_pszHelpFilePath;
switch ( dwData ) {
case HIDR_MAINFRAME:
case HIDR_MFCWIZTYPE:
case HIDD_ABOUTBOX:
case HIDD_TESTDLG:
//Topics that need to go into the main window.
HtmlHelp(m_hWnd, helpFilePath, HH_HELP_CONTEXT, dwData);
break;
case WHATEVER
//Topics that need to go into a different secondary window
...
break;
default:
//All the rest are popups
HtmlHelp(m_hWnd, helpFilePath, HH_HELP_CONTEXT, dwData);
break; }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM