
251
USING ROBOHELP HTML 9
Context-sensitive Help
Last updated 12/14/2011
BOOL ShowHelp(LPCTSTR szTopic, BOOL bIsLocal)
{
TCHAR szDir[MAX_PATH] = "";
if (bIsLocal)
{
// Get directory of application
DWORD dw = GetModuleFileName(AfxGetInstanceHandle(), szDir, MAX_PATH);
TCHAR* pchEnd = _tcsrchr(szDir, '\\') + 1;
ASSERT_POINTER(pchEnd, TCHAR);
*pchEnd = '\0';
// Append subfolder name
_tcscat(szDir, _T("Help"));
}
// Open topic
HINSTANCE hinst = ShellExecute(NULL, //no parent hwnd
NULL, // open
szTopic, // topic file or URL
NULL, // no parameters
szDir, // folder containing file
SW_SHOWNORMAL); // yes, show it
// handle less than 32 indicates failure
return hinst > (HINSTANCE)32;
}
.......................................................................................................................................
The
ShowHelp
function requires an explicit filename or URL. But for context-sensitive Help, it is better to code the
application to use context IDs rather than explicit topic names. Use the following sample function,
ShowHelpContext
,
which maps integer context IDs to topic name strings, then calls
ShowHelp
to open the topic.
BOOL ShowHelpContext(int nContextId)
{
CString strTopic;
BOOL bIsLocal = TRUE;
switch (nContextId)
{
case HH_GADGET_DIALOG:
strTopic = _T("gadget.htm");
break;
case HH_WHATSIT_DIALOG:
strTopic = _T("whatsit.htm");
break;
case HH_WIDGET_DIALOG:
strTopic = _T("widget.htm");
break;
case HH_TECH_SUPPORT:
strTopic = _T("http://www.mycompany.com");
bIsLocal = FALSE;
break;
default:
strTopic = _T("unknown-context.htm");
break;
}
return ShowHelp(strTopic, bIsLocal);
}
...........................................................................................................................................
Содержание 65030089 - Robohelp - PC
Страница 1: ...Using ADOBE ROBOHELP HTML 9...