📄 ch11.htm
字号:
<HTML>
<HEAD>
<TITLE>Special Edition Using Visual C++ 5 - Chapter 11</TITLE>
<LINK REL="Next" HREF="ch12.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/ch12.htm">
<LINK REL="Previous" HREF="ch10.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/ch10.htm"></HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H2><B>Chapter 11</B></H2>
<H2><B>Help</B></H2>
<hr>
<ul>
<li> <B>Types of Help</B></P>
<P> There are a number of different kinds of Help. Users, developers, and technical writers all divide Help along different lines.</P>
<li> <B>The file types that make up Help</B></P>
<P> AppWizard and the Help compiler between them generate over 10 files related to Help. This section explains them.</P>
<li> <B>What AppWizard provides</B></P>
<P> Code is added to your program and files are added to your project when you ask for context-sensitive Help.</P>
<li> <B>Designing your Help</B></P>
<P> Good Help, like a good program, is designed before it is implemented. There are many tasks involved in the implementation, and there's a risk of getting lost if you're not sure where you're going.</P>
<li> <B>Connecting command Help to your application</B></P>
<P> Dealing with Windows messages associated with menu items or buttons that request Help is quite simple.</P>
<li> <B>Connecting context Help to your application</B></P>
<P> Dealing with Windows messages requesting context-sensitive Help is more difficult, but can be done. This section works you through it.</P>
<li> <B>Composing Help text in Word</B></P>
<P> Using Word to compose Help files means learning all about footnote types, hidden text, and more. This section adds Help to an existing application to demonstrate the work involved.</P>
<li> <B>Help table of contents</B></P>
<P> Making sure the user can reach your new topics from the Help Contents list is vital. The Help Workshop tool included with Visual C++ makes it simple.</P>
</ul>
<P>Too many programmers neglect Help entirely. 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 of the reasons people do this is because they believe implementing Help is really hard. But with Visual C++, 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 <A HREF="index09.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index09.htm" target="text">Chapter 9</A>, "Building a Complete Application: ShowString."</P>
<H3><B>Different Kinds of Help</B></H3>
<P>There are a variety of ways of characterizing Help. 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 on-screen?</P>
<li> What sort of answers does the user want?</P>
<li> How does the developer implement it in code?</P>
</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 has a number of different techniques, which can be confusing at first.</P>
<P><B>Getting Help</B></P>
<P>The first way of characterizing Help is to ask "How does the user bring it up?" There are a number of ways to bring up Help:</P>
<ul>
<li> By choosing an item from the <U>H</U>elp menu, such as <U>H</U>elp, <U>T</U>opics (Choosing <U>W</U>hat's This? or <U>A</U>bout does not bring up Help immediately.)</P>
<li> By pressing F1</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 <U>W</U>hat's This? from the <U>H</U>elp 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 <U>W</U>hat'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</P>
</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 get into "Help mode"
(more formally called "What's This?" mode) and another to indicate what Help is required. Users generally divide Help into single-step Help and two-step Help accordingly.</P>
<blockquote><p><img src="note.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/note.gif">
<P>You will get confused if you try to use Developer Studio itself to understand Help, in general. Much of the information is presented in HTML by InfoViewer, 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. If you have old versions of software like Word or Excel, they probably don't follow the Windows 95 guidelines for Help either, because
these are quite different than the old Help guidelines.</P>
<p><img src="bottom.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/bottom.gif"></blockquote>
<P><B>Presenting Help</B></P>
<P>The second way of characterizing Help is to ask "How does it look?" There are a number of different-looking ways of showing Help:</P>
<ul>
<li> <B>Help Topics dialog box.</B> As shown in Figure 11.1, this dialog box allows users to scroll through an index, look at a table of contents, or find a word within the Help text.</P>
<li> <B>Ordinary Help window.</B> As shown in Figure 11.2, this window has buttons like 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.</P>
<li> <B>Pop-up windows.</B> As shown in Figure 11.3, pop-up windows are relatively small and do not 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.</P>
</ul>
<A HREF="Mfigs01.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/figs/ch11/Mfigs01.gif"><b>Fig. 11.1</b></A>
<P><I>The Help Topics dialog box allows users to go through the contents or index, or search the Help text with </I><I>Find.</I></P>
<A HREF="Mfigs02.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/figs/ch11/Mfigs02.gif"><b>Fig. 11.2</b></A>
<P><I>An ordinary Help window has buttons and may have menus. It can be treated like any other window.</I></P>
<A HREF="Mfigs03.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/figs/ch11/Mfigs03.gif"><b>Fig. 11.3</b></A>
<P><I>A pop-up Help topic window gives the user far less control and should be used only for short explanations.</I></P>
<P><B>Using Help</B></P>
<P>A third way of characterizing Help, is according to the user's reasons for invoking it. Microsoft categorizes Help in this way and lists these kinds of Help:</P>
<ul>
<li> <B>Contextual user assistance.</B> Answers questions like "What does this button do?" or "What does this setting mean?"</P>
<li> <B>Task-oriented Help.</B> Explains how to accomplish a certain task such as printing a document (it often contains numbered steps).</P>
<li> <B>Reference Help.</B> Look up function parameters or font names, or other material that expert users need to refer to from time to time.</P>
</ul>
<P>These describe the content of the material presented to the user. While these content descriptions are important to a Help designer and writer, they are not very useful from a programming point of view.</P>
<P><B>Programming Help</B></P>
<P>The final way of characterizing Help, and perhaps the most important to a developer, is by examining the code behind the scenes. There are three Windows messages that are sent when the user invokes Help in any of these ways:</P>
<ul>
<li> <font color="#008000">WM_COMMAND</font></pre>
<li> <font color="#008000">WM_HELP</font></pre>
<li> <font color="#008000">WM_CONTEXTMENU</font></pre>
</ul>
<blockquote><p><img src="note.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/note.gif">
<P>Windows messages are discussed in <A HREF="index04.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index04.htm" target="text">Chapter 4</A>, "Messages and Commands."</P>
<p><img src="bottom.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/bottom.gif"></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 <font color="#008000">WM_COMMAND</font> 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 <font color="#008000">WM_CONTEXTMENU</font> 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 pre-built menu with just 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 brings up Help in any other way, the framework handles most of it. You do not catch the message that puts the application into What's This? mode, you do not change the cursor, and you do not deal with clicks while in that mode. You catch
a <font color="#008000">WM_HELP</font> 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 does not matter. In
fact, you cannot tell from within your application.</P>
<P>The <font color="#008000">WM_HELP</font> and <font color="#008000">WM_CONTEXTMENU</font> 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 are discussed later in this chapter, in the "Programming for Command Help" and "Programming for Context Help" sections, but keep in mind that there is 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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -