📄 ch11.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function popUp(pPage) {
var fullURL = document.location;
var textURL = fullURL.toString();
var URLlen = textURL.length;
var lenMinusPage = textURL.lastIndexOf("/");
lenMinusPage += 1;
var fullPath = textURL.substring(0,lenMinusPage);
popUpWin = window.open('','popWin','resizable=yes,scrollbars=no,width=525,height=394');
figDoc= popUpWin.document;
zhtm= '<HTML><HEAD><TITLE>' + pPage + '</TITLE>';
zhtm += '<link rel="stylesheet" href="/includes/stylesheets/ebooks.css"></head>';
zhtm += '<BODY bgcolor="#FFFFFF">';
zhtm += '<IMG SRC="' + fullPath + pPage + '">';
zhtm += '<P><B>' + pPage + '</B>';
zhtm += '</BODY></HTML>';
window.popUpWin.document.write(zhtm);
window.popUpWin.document.close();
// Johnny Jackson 4/28/98
}
//-->
</SCRIPT>
<link rel="stylesheet" href="ebooks.css" tppabs="http://www.fintech.ru/includes/stylesheets/ebooks.css">
<TITLE>Special Edition Using Visual C++ 6 -- Ch 11 -- Help</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
<CENTER>
<H1><IMG SRC="que.gif" tppabs="http://www.fintech.ru/library/prog/SEUsingVC6/button/que.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM" BORDER="0"><BR>
Special Edition Using Visual C++ 6</H1>
</CENTER>
<CENTER>
<P><A HREF="ch10.htm" tppabs="http://www.fintech.ru/library/prog/SEUsingVC6/ch10/ch10.htm"><IMG SRC="previous.gif" tppabs="http://www.fintech.ru/library/prog/SEUsingVC6/button/previous.gif" WIDTH="128" HEIGHT="28"
ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="ch12.htm" tppabs="http://www.fintech.ru/library/prog/SEUsingVC6/ch12/ch12.htm"><IMG
SRC="next.gif" tppabs="http://www.fintech.ru/library/prog/SEUsingVC6/button/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"
BORDER="0"></A><A HREF="index.htm" tppabs="http://www.fintech.ru/library/prog/SEUsingVC6/index.htm"><IMG SRC="contents.gif" tppabs="http://www.fintech.ru/library/prog/SEUsingVC6/button/contents.gif" WIDTH="128"
HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A>
<HR>
</CENTER>
<CENTER>
<H1>- 11 -</H1>
</CENTER>
<CENTER>
<H1>Help</H1>
</CENTER>
<UL>
<LI><A HREF="#Heading1">Different Kinds of Help</A>
<UL>
<LI><A HREF="#Heading2">Getting Help</A>
<LI><A HREF="#Heading3">Presenting Help</A>
<LI><A HREF="#Heading4">Using Help</A>
<LI><A HREF="#Heading5">Programming Help</A>
</UL>
<LI><A HREF="#Heading6">Components of the Help System</A>
<LI><A HREF="#Heading7">Help Support from AppWizard</A>
<LI><A HREF="#Heading8">Planning Your Help Approach</A>
<LI><A HREF="#Heading9">Programming for Command Help</A>
<LI><A HREF="#Heading10">Programming for Context Help</A>
<LI><A HREF="#Heading11">Writing Help Text</A>
<UL>
<LI><A HREF="#Heading12">Changing Placeholder Strings</A>
<LI><A HREF="#Heading13">Adding Topics</A>
<LI><A HREF="#Heading14">Changing the How to Modify Text Topic</A>
</UL>
<LI><A HREF="#Heading15">Adjustments to the Contents</A>
</UL>
<P>
<HR SIZE="4">
<CENTER>
<H1></H1>
</CENTER>
<P>Too many programmers entirely neglect online Help. Even those who add Help to
an application tend to leave it to the end of a project, and when the inevitable
time squeeze comes, guess what? There's no time to write the Help text or make the
software adjustments that arrange for that text to display when the user requests
Help. One reason people do this is because they believe implementing Help is really
hard. With Visual C++, though, it's a lot easier than you might anticipate. Visual
C++ even writes some of your Help text for you! This chapter is going to add Help,
after the fact, to the ShowString application built in Chapter 8, "Building
a Complete Application: ShowString."</P>
<P>
<H2><A NAME="Heading1"></A>Different Kinds of Help</H2>
<P>You can characterize Help in a variety of ways. This section presents four different
questions you might ask about Help:</P>
<UL>
<LI>How does the user invoke it?
<P>
<LI>How does it look onscreen?
<P>
<LI>What sort of answers does the user want?
<P>
<LI>How does the developer implement it in code?
</UL>
<P>None of these questions has a single answer. There are at least nine different
ways for a user to invoke Help, three standard Help appearances, and three different
programming tasks you must implement in order to display Help. These different ways
of looking at Help can help you understand why the implementation involves a number
of different techniques, which can be confusing at first.</P>
<P>
<H3><A NAME="Heading2"></A>Getting Help</H3>
<P>The first way of characterizing Help is to ask "How does the user open it
up?" There are a number of ways to open Help:</P>
<UL>
<LI>By choosing an item from the Help menu, such as Help, Contents (choosing What's
This? or About doesn't open Help immediately)
<P>
<LI>By pressing the F1 key
<P>
<LI>By clicking the Help button on a dialog box
<P>
<LI>By clicking a What's This? button on a toolbar and then clicking something else
<P>
<LI>By choosing What's This? from the Help menu (the System menu for dialog box-based
applications) and then clicking something
<P>
<LI>By clicking a Question button on a dialog box and then clicking part of the dialog
box
<P>
<LI>By right-clicking something and choosing What's This? from the pop-up menu
<P>
<LI>In some older applications, by pressing Shift+F1 and then clicking something
<P>
<LI>Outside the application completely, by double-clicking the HLP file
</UL>
<P>For the first three actions in this list, the user does one thing (chooses a menu
item, presses F1, or clicks a button), and Help appears immediately. For the next
five actions, there are two steps: typically, one click to go into Help mode (more
formally called What's This? mode) and another to indicate which Help is required.
Users generally divide Help into single-step Help and two-step Help, accordingly.</P>
<BLOCKQUOTE>
<P>
<HR>
<strong>NOTE:</strong> You will become confused if you try to use Visual Studio to understand
Help, in general. Much of the information is presented as HTML Help in a separate
product, typically MSDN, though there are some circumstances under which more traditional
Help appears. Use simple utilities and accessories that come with your operating
system or use your operating system itself to follow along. 
<HR>
</P>
<P>
<HR>
<B>HTML Help</B></P>
<P>Until fairly recently, all Help files were built from RTF files, as described
in this chapter, and displayed with the Microsoft Help engine. Microsoft has now
started to use HTML files for its Help, and has released a number of tools to simplify
the job of creating and maintaining HTML Help.</P>
<P>There are a number of advantages to an HTML Help system: Your Help files can contain
links to Internet resources, for example. You can incorporate any active content
that your browser understands, including ActiveX controls, Java applets, and scripting.
Many developers find attractive Help systems quicker to build in HTML.</P>
<P>Unfortunately, there are also disadvantages. The interface is not as rich as the
traditional Help interface, for example. Many developers take one look at the HTML
Help provided with Visual Studio and vow never to produce HTML Help files for their
own products.</P>
<P>If you would like to use HTML Help rather than the traditional Help files discussed
in this chapter, start by visiting <A target="_new" HREF="javascript:if(confirm('http://www.microsoft.com/workshop/author/htmlhelp \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.microsoft.com/workshop/author/htmlhelp'" tppabs="http://www.microsoft.com/workshop/author/htmlhelp"><B>http://www.microsoft.com/workshop/author/htmlhelp</B></A>
to get a copy of the HTML Help Workshop and plenty of documentation and examples.</P>
<P>Most of the work involved in creating HTML Help is the same as the traditional
Help techniques presented here, but involves, for example, calling HTMLHelp() instead
of ::WinHelp(). Instead of editing RTF files with Word, you edit HTML files with
the HTML Help Workshop editor.
<HR>
</BLOCKQUOTE>
<H3><A NAME="Heading3"></A>Presenting Help</H3>
<P>The second way of characterizing Help is to ask, "How does it look?"
You can display Help in several ways:</P>
<UL>
<LI><I>Help Topics dialog box</I>. As shown in Figure 11.1, this dialog box enables
users to scroll through an index, look at a table of contents, or find a word within
the Help text. (To open this dialog on Windows, choose Start, Help.)
<P>
<LI><I>Ordinary Help window</I><B>.</B> As shown in Figure 11.2, this window has
buttons such as Help Topics, Back, and Options. It can be resized, minimized, maximized,
or closed and in many cases is always on top, like the system clock and other popular
utilities. (To see this one, open the calculator, usually by choosing Start, Programs,
Accessories, Calculator; then press F1. Expand a closed book by double-clicking it;
then double-click a topic from the list that appears. Finding Out What a Calculator
Button Does appears under Tips and Tricks.)
<P>
<LI><I>Pop-up windows</I><B>.</B> As shown in Figure 11.3, pop-up windows are relatively
small and don't have buttons or menus. They disappear when you click outside them,
cannot be resized or moved, and are perfect for a definition or quick explanation.
To re-create Figure 11.3, right-click the MC button and choose What's This?
</UL>
<P><A HREF="javascript:popUp('11fig01.gif')"><B>FIG. 11.1</B></A><B> </B><I>The Help
Topics dialog box enables users to go through the contents or index or search the
Help text with Find.</I></P>
<P><I><BR>
</I><A HREF="javascript:popUp('11fig02.gif')"><B>FIG. 11.2</B></A><B> </B><I>An ordinary
Help window has buttons and sometimes menus. It can be treated like any other window.</I></P>
<P><I><BR>
</I><A HREF="javascript:popUp('11fig03.gif')"><B>FIG. 11.3</B></A><B> </B><I>A pop-up
Help topic window gives the user far less control and should be used only for short
explanations.</I></P>
<H3><I></I></H3>
<H3><A NAME="Heading4"></A>Using Help</H3>
<P>A third way of characterizing Help is according to the user's reasons for invoking
it. In the book<I> The Windows Interface Guidelines for Software Design,</I> Microsoft
categorizes Help in this way and lists these kinds of Help:</P>
<UL>
<LI><I>Contextual user assistance</I> answers questions such as What does this button
do? or What does this setting mean?
<P>
<LI><I>Task-oriented Help</I> explains how to accomplish a certain task, such as
printing a document. (It often contains numbered steps.)
<P>
<LI><I>Reference Help</I> looks up function parameters, font names, or other material
that expert users need to refer to from time to time.
<P>
<LI><I>Wizards </I>walk a user through a complicated task, just as AppWizard walks
you through creating an application.
</UL>
<P>These describe the content of the material presented to the user. Although these
content descriptions are important to a Help designer and writer, they're not very
useful from a programming point of view.</P>
<BLOCKQUOTE>
<P>
<HR>
<strong>TIP:</strong> The book mentioned previously is provided with the MSDN CDs included
with Visual Studio. In Visual Studio, press F1 to bring up MSDN. On the Contents
tab of MSDN, expand the Books item, then expand the interface guidelines book. Chapter
12, "User Assistance," gives Help guidelines.
<HR>
</BLOCKQUOTE>
<H3><A NAME="Heading5"></A>Programming Help</H3>
<P>The final way of characterizing Help, and perhaps the most important to a developer,
is by examining the code behind the scenes. Three Windows messages are sent when
the user invokes Help:</P>
<UL>
<LI>WM_COMMAND
<P>
<LI>WM_HELP
<P>
<LI>WM_CONTEXTMENU
</UL>
<BLOCKQUOTE>
<P>
<HR>
<strong>NOTE:</strong> Windows messages are discussed in Chapter 3, "Messages and Commands."
<HR>
</BLOCKQUOTE>
<P>When the user chooses a Help item from a menu or clicks the Help button on a dialog
box, the system sends a WM_COMMAND message, as always. To display the associated
Help, you catch these messages and call the WinHelp system.</P>
<P>When the user right-clicks an element of your application, a WM_CONTEXTMENU message
is sent. You catch the message and build a shortcut menu on the spot. Because in
most cases you will want a shortcut menu with only one item on it, What's This?,
you can use a prebuilt menu with only that item and delegate the display of that
menu to the Help system--more on this later in the "Programming for Context
Help" section.</P>
<P>When the user opens Help in any other way, the framework handles most of it. You
don't catch the message that puts the application into What's This? mode, you don't
change the cursor, and you don't deal with clicks while in that mode. You catch a
WM_HELP message that identifies the control, dialog box, or menu for which Help is
required, and you provide that Help. Whether the user pressed F1 or went into What's
This? mode and clicked the item doesn't matter. In fact, you can't tell from within
your application.</P>
<P>The WM_HELP and WM_CONTEXTMENU messages are handled almost identically, so from
the point of view of the developer, there are two kinds of help. We'll call these
<I>command help</I> and <I>context help</I>. Each is discussed later in this chapter
in the "Programming for Command Help" and "Programming for Context
Help" sections, but keep in mind that there's no relationship between this split
(between command and context help) and the split between one-step and two-step Help
that users think of.</P>
<P>
<H2><A NAME="Heading6"></A>Components of the Help System</H2>
<P>As you might expect, a large number of files interact to make online Help work.
The final product, which you deliver to your user, is the Help file, with the .hlp
extension. It is built from component files. In the list that follows, <I>appname</I>
refers to the name of your application's .exe file. If no name appears, there might
be more than one file with a variety of names. The component files produced by AppWizard
are as follows:</P>
<P><BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -