Making Help context sensitive
To make your help context sensitive you'll need to make some changes to
your help project file and to your VB project.Step
1: Open your VB project and select View, Project Explorer to see the contents of
your project. Double-click on the module file called modQuote.bas to open it.
Step 2: You'll need to add the API function
declaration for WinHelp to your module to allow you to access the Windows help engine from
within your project. The function declaration you need is in the box 'The API function
declaration' and you'll need to type this in at the top of the module. Type it exactly as
it is as one long statement -- don't break it across lines (see Figure 3e).
Alternatively, like all API function declarations, you can
use your API Text Viewer to locate the function declaration so you can copy and paste it
into your application -- see the instructions in the box 'Copying API function'.
Step 3: Open your help project file
(quotes.hpj) and add these lines of text to the foot of the file and then save it again as
a text file called quotes.hpj (see Figure 4e). You should ignore any lines which the
compiler may have added to it.
[MAP]
IDH_MAIN 1
QuoteDef 2
AddQuotes 3
EditQuotes 4
NavigateQuotes 5
MainScreen 6
ManageQuotes 7
Step 4: Use Help Workshop to recompile your
help file. What you have done in these last steps is to give all the Topic IDs in your
help topic file a numeric reference in a process called 'mapping'. As long as each numeric
reference is unique, you can use any numbers, sequential or not.
Step 5: Switch back to your VB Project and
display the form called frmDisplayQuotes. In the form's properties list set the
HelpContextID to 1. Repeat this for the form frmManageQuotes and set its HelpContextID to
7.
Step 6: Save your VB project and then run it
so you can test the context sensitivity. From the Daily Quotes screen press F1 and notice
how the main help screen appears this time instead of the Help Index. Close your help
file, select the Quotes button and when you have the Manage quotes screen visible, press
F1 again and notice that a different help topic is displayed.
You can link different help topics to different objects in
your project -- not just to form objects. Simply set the HelpContextID property of any
object to the number of the Topic ID that you want to display whenever that object has the
focus and the user selects the F1 key.
|