Adding Visual Help to an Application

There are two ways to implement visual Help in an application. You can associate a help topic or index with an application using the IfmManage::put_HelpContext method, or you can associate a help topic or index with a form using the IASForm::put_HelpContext method. The two put_HelpContext methods use the same parameters.

The following code example shows the syntax for calling a visual Help index or topic file.

put_HelpContext(bstrIndexFile, bstrTopicFile);

    To call a Help index

  1. Before your application initializes, call put_HelpContext to call a Help index for an object.

    When you call put_HelpContext, the Forms Manager automatically handles the VK_HELP event.

  2. Call the SysAllocString function to allocate a string and copy the Help index file name into it. The Help files must be in the same directory as your executable file.
  3. SysAllocString returns NULL if there is insufficient memory.
  4. Call put_HelpContext for your application’s IfmManage object, and specify the file name of the Help index.
  5. Call SysFreeString to free the string allocated previously by SysAllocString.

The following code example shows how to set up a Help context with a Help index file by calling put_HelpContext. Again, check the memory allocation return value to ensure it did not fail.

BSTR bstrIndexFile = SysAllocString(L"\\path\\help-index.html");
pManage->put_HelpContext(bstrIndexFile, NULL);
SysFreeString(bstrIndexFile);

    To call a Help topic

  1. Before your application initializes, call put_HelpContext to call a Help topic.
  2. Call the SysAllocString function to allocate a string and copy the Help topic file name into it. The Help files must be in the same directory as your executable file.

    SysAllocString returns NULL if there is insufficient memory.

  3. Call put_HelpContext for your application’s IfmManage object, and specify the file name of the Help topic.
  4. Call SysFreeString to free the string allocated previously by SysAllocString.

The following code example shows how to set up a Help context with a Help topic file by calling put_HelpContext. Again, check the memory allocation return value to ensure it did not fail.

BSTR bstrTopicFile = SysAllocString(L"\\path\\help-topic.html");
pManage->put_HelpContext(NULL, bstrTopicFile);
SysFreeString(bstrTopicFile);