ADC Home > Reference Library > Technical Q&As > User Experience > Help Technologies >

Displaying Help


Q: My application's help is provided in a collection of HTML files viewable in the Help Viewer. What is the quickest way to display information about a particular topic?

A: Your application can call the AHLookupAnchor routine to display help about particular topics in your help files. AHLookupAnchor asks the Help Viewer to search your application's help book and present the page containing a particular HTML anchor scrolled so the anchor's location is visible.




     /* GoToMyHelpAnchor can be used to tell Apple Help to find
    the page containing the named anchor and display the text
    immediately below that anchor in the main view.

    anchorName - the name of the anchor you would like to display.
    This routine illustrates a convenient way to use the AHLookupAnchor
    routine to look up anchors in your application's help book.  */

OSStatus GoToMyHelpAnchor(CFStringRef anchorName) {
    CFBundleRef myAppsBundle;
    CFTypeRef myBookName;
    OSStatus err;

        /* set up a known state */
    myAppsBundle = NULL;
    myBookName = NULL;

        /* Get our application's main bundle
        from Core Foundation */
    myAppsBundle = CFBundleGetMainBundle();
    if (myAppsBundle == NULL) { err = fnfErr; goto bail; }

        /* get the help book's name */
    myBookName = CFBundleGetValueForInfoDictionaryKey(
                   myAppsBundle, CFSTR("CFBundleHelpBookName"));
    if (myAppsBundle == NULL) { err = fnfErr; goto bail; }

        /* go to the page */
    err = AHLookupAnchor( myBookName, anchorName);
    if (err != noErr) goto bail;

        /* done */
    return noErr;
bail:
    return err;
}

Examples:

err = GoToMyHelpAnchor(CFSTR("surfing"));
err = GoToMyHelpAnchor(CFSTR("seaboards"));

Listing 1. Displaying help using the AHLookupAnchor routine.



Using AHLookupAnchor in your application means your application does not need to keep track of the names of the files where particular help content appears - your application only needs to track the anchor name used to locate particular help content.

This allows your help content creators greater freedom when designing and maintaining your help content as they can move information from file to file or redesign the look of your help pages without worrying about the help book getting out of sync with how your application asks the Help Viewer to present information about particular topics.


[Feb 21 2001]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.