Article

Context-Sensitive Help

Context-Sensitive Help

"The tag property takes a string value." That's what PB Help tells us about the tag property. Not much considering all or at least most PB objects have a "tag" property. What's its mission in life? Anything we want it to be.

You could use the object's tag property to set MicroHelp in an MDI frame with the code in a GetFocus event, for example:

w_frame.SetMicroHelp(This.Tag)

However, the time-honored use has been for context-sensitive help. By putting a distinct "keyword" for that object in the tag property, you can grab this text and pass it to the ShowHelp function. Just what event triggers the ShowHelp function is up to you. My favorite use has been to code a Key event to detect if the F1 key has been pressed. This is a good candidate to add to the objects in your base class hierarchy if you're absolutely sure you'll be using context-sensitive help. Put the name of the help file in a property of a user object and load the object at startup along with other "system" instance variables turned properties. Or simply tuck it into the registry area of your application.

There are two arguments in a Key event to get familiar with, key and keyflags. Key is the actual enumerated datatype of the key that was pressed, and keyflag is any modifier key (shift, alt, or control) that was also pressed. In the following example, only if the user presses F1 by itself will we trigger the help process.

IF keyflags = 0 THEN
IF key = KeyF1! THEN
ShowHelp ( "pbdj.hlp", KeyWord!, this.tag )
END IF
END IF

Alas, the trick here is not the code in your PB app, that's pretty simple; the tough part is building the "help" file. Microsoft has had help files (.hlp) since day one. You can still find the original MS Help Compiler on the Web and really code this the old-fashioned way, but there are many tools now available to make this a simple chore. Some are shareware with a minimal cost to register; others require some serious cash. The most well-known and one of the most expensive is RoboHelp from eHelp Corp. Since it's an add-on to MS Word, you can make some very elaborate help systems within Word with a fairly small learning curve.

If you're going to be developing some serious help files and lots of them, cough up the $379 and go with RoboHelp X3 for Word. There are other versions to choose from and price tags to match. You can grab a 15-day demo copy at www.ehelp.com/products/robohelp/downloads.asp.

For those of us without that much cash to burn or who would only use it infrequently, there's a cheaper way. But don't get too excited, it's cheaper and far less functional, but good in a pinch. If you don't mind rolling up your sleeves and doing some of your own coding, you might try Help Hikes Pro from KanadePro.com. Registration is $25 (see Figure 1). Download it from http://kanadepro.com/helphikes/download.shtml.

To make a help file, I suggest planning the file in much the same way you'd plan a Web site. What are your hyperlinks and what will they link to? What are the keywords or index? I like to use an Excel spreadsheet and make a list of the objects in my system and what the keyword will be for each one. Make sure you don't duplicate keywords. I've been using keyword as the example, but if you look at the help file for ShowHelp it will show that you can use either keywords, a finder, a topic, or the help index. Try all of them to see the functionality each one provides. You might use an index from the menu bar item for system help, keywords for objects, and topics for help within objects, for example.

When you're finished, all you need to send is the .hlp file along with your application, unless there are other utilities that the help authoring system requires.

Putting context-sensitive help in your applications will make your work a cut above the rest of the crowd. Happy coding!

More Stories By David Hart

David Hart is a former Sybase Tools and Database Instructor. He is a certified PB developer and certified ASE DBA from Rancho Cucamonga, CA. He is currently on contract assignments in Southern California.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.