⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vcg23.htm

📁 Visual C++与数据库的连接经典实例
💻 HTM
📖 第 1 页 / 共 5 页
字号:

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE><B>NOTE</B>

<BR>

<BR>Generally, if you delegate the help file authoring, whoever was doing the help file development would use the MakeHelp.Bat file to create the help files rather than Visual C++'s Developer Studio.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<P>

<FONT COLOR="#000080"><B>Listing 23.1. A typical MakeHelp.Bat file.</B></FONT>

<BR>

<PRE>

<FONT COLOR="#000080">@echo off

REM -- First make map file from Microsoft Visual C++ generated resource.h

echo // MakeHelp.Bat generated Help Map file.

    Used by HELP FILE DEMO.HPJ. &gt;&quot;hlp\Help File Demo.hm&quot;

echo. &gt;&gt;&quot;hlp\Help File Demo.hm&quot;

echo // Commands (ID_* and IDM_*) &gt;&gt;&quot;hlp\Help File Demo.hm&quot;

makehm ID_,HID_,0x10000 IDM_,HIDM_,0x10000 resource.h &gt;&gt;&quot;hlp\Help File Demo.hm&quot;

echo. &gt;&gt;&quot;hlp\Help File Demo.hm&quot;

echo // Prompts (IDP_*) &gt;&gt;&quot;hlp\Help File Demo.hm&quot;

makehm IDP_,HIDP_,0x30000 resource.h &gt;&gt;&quot;hlp\Help File Demo.hm&quot;

echo. &gt;&gt;&quot;hlp\Help File Demo.hm&quot;

echo // Resources (IDR_*) &gt;&gt;&quot;hlp\Help File Demo.hm&quot;

makehm IDR_,HIDR_,0x20000 resource.h &gt;&gt;&quot;hlp\Help File Demo.hm&quot;

echo. &gt;&gt;&quot;hlp\Help File Demo.hm&quot;

echo // Dialogs (IDD_*) &gt;&gt;&quot;hlp\Help File Demo.hm&quot;

makehm IDD_,HIDD_,0x20000 resource.h &gt;&gt;&quot;hlp\Help File Demo.hm&quot;

echo. &gt;&gt;&quot;hlp\Help File Demo.hm&quot;

echo // Frame Controls (IDW_*) &gt;&gt;&quot;hlp\Help File Demo.hm&quot;

makehm IDW_,HIDW_,0x50000 resource.h &gt;&gt;&quot;hlp\Help File Demo.hm&quot;

REM -- Make help for Project HELP FILE DEMO

echo Building Win32 Help files

start /wait hcrtf -x &quot;hlp\Help File Demo.hpj&quot;

echo.

if exist Debug\nul copy &quot;hlp\Help File Demo.hlp&quot; Debug

if exist Debug\nul copy &quot;hlp\Help File Demo.cnt&quot; Debug

if exist Release\nul copy &quot;hlp\Help File Demo.hlp&quot; Release

if exist Release\nul copy &quot;hlp\Help File Demo.cnt&quot; Release

echo.</FONT></PRE>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE><B>NOTE</B>

<BR>

<BR>Visual C++ 2.x's AppWizard might add an EndLocal statement to the end of the MakeHelp.Bat file. This command should cause no problems (even though it isn't currently supported by DOS). Oddly, AppWizard doesn't include an opening SetLocal statement.

<BR>

<BR>Visual C++ 4 doesn't add the erroneous EndLocal statement. Instead, it adds an Echo command to the end of MakeHelp.Bat, as Listing 23.1 shows.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<P>After you've created your project, you will compile the initial help files when you first build your project. You don't need to make any changes in these files; however, you will find that as supplied by AppWizard, the help files don't provide much help!

<BR>

<P>The AfxCore.rtf file has a number of place markers. These are marked with the characters &lt;&lt; and &gt;&gt;. For example, you will need to substitute the application's name wherever the phrase &lt;&lt;<I>AppName</I>&gt;&gt; is found. To do this, simply use a global substitution command in Word for Windows or whichever RTF editor you're using.

<BR>

<P>Any place markers that aren't listed in the help source file are verbose enough that you will readily understand what information needs to be substituted.

<BR>

<P><B>WARNING</B>

<BR>

<BR>The WordPad editor that is part of Windows 95 can't be used to create help files. This is because help file topics are linked to footnotes, and WordPad doesn't support footnotes. You must use a fully functional RTF-enabled editor, such as Word for Windows, to create or modify a help .RTF file.

<BR>

<A NAME="E69E280"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Creating Rich Text Format Files for Help Systems</B></FONT></CENTER></H4>

<BR>

<P>A WinHelp .HLP file is a compiled version of a word processing document file saved in Microsoft rich text format (RTF). <I>Rich text format</I> is a page description language used to exchange formatted text between document processing applications. For example, you use .RTF files to transfer Word for Windows files to the Macintosh version of Word. Most Windows word processing applications can save documents as .RTF files. Rich text format is similar in concept to Adobe's PostScript page description language, but .RTF isn't used to print documents. Figure 23.3 shows part of the .RTF version of AfxCore.rtf (the CHAPTR23\Help File Demo\hlp\AfxCore.rtf file) displayed in Notepad's window. Figure 23.4 shows the same file loaded into Word for Windows.

<BR>

<P><B><A HREF="23vcg03.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/23vcg03.gif">Figure 23.3. Part of the AfxCore.rtf WinHelp file in Notepad.</A></B>

<BR>

<P><B><A HREF="23vcg04.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/23vcg04.gif">Figure 23.4. The same part of the AfxCore.rtf WinHelp file in Word for Windows.</A></B>

<BR>

<P>The .RTF files that you create include a header that describes the page format, fonts, and styles in use. PostScript files contain a header that serves a similar purpose. An escape character (\) precedes page and character formatting data in .RTF files, and French braces ({}) enclose groups of formatting data and text to which the formatting applies. Most of the header information in Word .RTF files is derived from the template (.DOT file) in use when you write the document. Only a small part of the .RTF file header appears in Figure 23.3; the first few words of the text are highlighted to identify the point where the paragraph starts.

<BR>

<BR>

<A NAME="E69E281"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Adding Instructions to the WinHelp Engine</B></FONT></CENTER></H4>

<BR>

<P>Instructions to the WinHelp engine are embedded in the .RTF file in the form of footnotes designated by footnote symbols, such as $ and #, rather than conventional footnote numbers. Topic titles are designated by $ footnotes. The context strings that uniquely identify a topic to the WinHelp engine use the # symbol. A topic is a help window that is devoted to a single subject. Topics are separated from one another in your word processing document by hard page breaks (usually created using the Ctrl-Enter key combination). Figure 23.5 shows part of a simple help topic from the HELPEX example included with the <I>Windows Help Authoring </I><I>Guide</I> on the Microsoft Developer's Network CD-ROM.

<BR>

<P><B><A HREF="23vcg05.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/23vcg05.gif">Figure 23.5. Part of the second topic of the HELPEX.RTF file used to create HELPEX.HLP.</A></B>

<BR>

<P>In Figure 23.5, Help Example Index is the topic title and ctxContents is the help context string for the topic. <I>Hotspots</I> are individual words or blocks of text that are formatted with the double-underline or strikethrough attribute and are followed by a help context string formatted as hidden text. When you click a hotspot, WinHelp jumps to the topic identified by the context string that follows the hotspot text. Figure 23.6 shows the first two help topic windows of HELPEX.HLP. Hotspots appear in green in help windows, so you should avoid using the green color attribute in your help text.

<BR>

<P><B><A HREF="23vcg06.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/23vcg06.gif">Figure 23.6. The first two help topic windows of HELPEX.HLP.</A></B>

<BR>

<BR>

<A NAME="E69E282"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Including Graphic Objects in Your WinHelp File</B></FONT></CENTER></H4>

<BR>

<P>You can embed or link graphic objects contained in bitmap (.BMP) or vector image (.WMF) files in your WinHelp files. The easiest way to add bitmapped images to your help files is to embed the image in .BMP format in your .DOC or .RTF file using Word. However, large bitmap files usually are handled more efficiently by linking the graphic file to the WinHelp file by using its filename as a reference. Figure 23.7 shows Microsoft's logo as an embedded bitmap. Figure 23.8 shows Microsoft's logo as it appears in the final help file. To embed the bitmap (a bitmap image captured from Word for Windows' toolbar) in the .RTF document, you choose Insert | Picture in Word to display the Picture dialog box and then double-click cmdialog.bmp in the File Name list box. The {bmc cmdialog.bmp} entry below the line of text causes the CMDIALOG.BMP bitmap file to be inserted at the position of the { character.

<BR>

<P><B><A HREF="23vcg07.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/23vcg07.gif">Figure 23.7. A help topic with an embedded bitmap.</A></B>

<BR>

<P><B><A HREF="23vcg08.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/23vcg08.gif">Figure 23.8. An embedded bitmap of Microsoft's logo in WinHelp.</A></B>

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE><B>NOTE</B>

<BR>

<BR>When you use bitmapped graphics, you might need to include a version of the bitmap file for each type of display resolution that might be employed by users of the help system. The Microsoft multiple-resolution bitmap compiler, MRBC.EXE, lets you create a single bitmap file that supports VGA, SVGA, and 8514 resolutions. It's unlikely that any users of Visual C++ database applications will be using resolutions less than standard VGA, but MRBC.EXE is useful to provide scaleable bitmaps for 640x480 (VGA), 800x600 (SVGA), and 1,024x768 (8514, XGA, or UVGA) display resolutions. It won't be long before 1280x1024 resolutions become common. Your help files should take into account the trend toward higher resolution and more colors. Many Windows database applications still run on &quot;plain vanilla&quot; 16-color VGA systems, but more and more users are converting to 256-color or better systems. When you convert a .BMP file with MRBC.EXE, you substitute .MRB for the .BMP extension when you refer to the file. One of the advantages of using .WMF vector image files in help files is that the Windows metafiles are device-independent.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE><B>NOTE</B>

<BR>

<BR>The term <I>link</I> is used in this chapter to differentiate between embedding a graphics file in the .RTF file and creating a reference to a separate graphics file with {bm<I>?</I><I> </I><I>filename.ext</I>} entries in your .RTF file. The <I>?</I> placeholder determines whether the graphic is placed as a character (bmc), at the left margin (bml), or at the right margin (bmr). When you compile the help file with the WinHelp compiler, the graphic that you link is embedded into the .HLP file you create. (You don't need to supply the .BMP file along with your .HLP file.)</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<P>You can create hotspots in graphic images that you link to your WinHelp file by using the Hotspot Editor, SHED.EXE, which is included with Visual C++. (You can't add hotspots to bitmaps you embed in WinHelp .RTF files.)

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE><B>NOTE</B>

<BR>

<BR>If there is no link to SHED in the Visual C++ 4 folder, you can add one. An alternative is to start SHED from a DOS command prompt window, but this really isn't efficient unless you frequently use a DOS window.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<P>The Hotspot Editor creates an .SHG (system hypergraphic) file from .BMP, .DIB (device-independent bitmap), or .WMF files. To add hotspots to a .BMP, .DIB, or .WMF file, follow the next steps.

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE><B>NOTE</B>

<BR>

<BR>The bitmap file used in this example is setup.bmp, found in Windows 95's directory. It was copied to the help project folder and saved in SHED as setup.shg.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<OL>

<LI>Launch SHED.EXE and choose File | Open from the editor to display the File Open dialog box (which isn't a Windows 95 common dialog box).

<BR>

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE><B>NOTE</B>

<BR>

<BR>Because SHED isn't long-filename-compliant, you will have to select files using their short filenames.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<LI>Select the directory and filename of the bitmap in the Directories and Files list boxes, and then click the OK button to close the File Open dialog box and display the image.

<BR>

<BR>

<LI>Position the mouse pointer in the upper-left corner of the area that you want to make active as a hotspot. Click and hold the left mouse button, drag the enclosing rectangle to define the hotspot area, and then release the mouse button.

<BR>

<BR>

<LI>With the frame for your hotspot selected (the one with the eight sizing handles), choose Edit | Attributes to display the Attributes dialog box. Alternatively, you can select Attributes by right-clicking in the hotspot area. Enter the context string corresponding to the topic for the hotspot item in the Context String text box. Select Pop-up to create a pop-up window or select Jump to jump to a new topic. Accept the default value, Visible, in the Attribute combo box and the Hotspot ID text box. You can manipulate the position of the enclosing rectangle by changing the entries in the text boxes within the Bounding Box frame. Figure 23.9 shows the typical entries that define the attributes of a hotspot.

<BR>

<BR>

<P><B><A HREF="23vcg09.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/23vcg09.gif">Figure 23.9. Defining the boundaries and attributes of a hotspot in a hypergraphic (.SHG) file.</A></B>

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE><B>NOTE</B>

<BR>

<BR>All the hotspots in this example were defined as pop-ups. You can also define hotspots as either jumps (which would jump to a certain topic) or as a WinHelp macro that would be run when the hotspot was selected.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<LI>Click the OK button to assign the attributes to the hotspot. Add more hotspots as needed by repeating steps 3 and 4.

<BR>

<BR>

<LI>When you've completed the definitions of the hotspots you want, choose File | Save As and save your file with the same name as the original bitmap but with an .SHG extension to indicate that the bitmap file is now a hypergraphic file. Close SHED.EXE.

<BR>

<BR>

<LI>If you've used the .BMP extension to refer to the bitmap in your .RTF file, change the file extension to .SHG. (You also might need to change the reference in the [BITMAPS] section of the project file if the bitmaps are in folders other than the help file's project directory. This is discussed in the next section.)

<BR>

<BR>

<LI>Add new topics to your WinHelp file for the pop-up or conventional help windows that appear when you click the hotspots. Each topic has a context string that corresponds to the context string you added during the editing process. Figure 23.10 shows entries for the pop-up window that opens when you click the mouse hotspot on the bitmap.

<BR>

<BR>

<P><B><A HREF="23vcg10.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/23vcg10.gif">Figure 23.10. Pop-up help window topics for hotspots of the set up bitmap image.</A></B>

<BR><BR>

<LI>After you compile your WinHelp .RTF file to a .HLP file, clicking the hotspot displays the pop-up window that has a context string that corresponds to the context string you assigned as the hotspot's attribute. (Compiling .RTF to .HLP files is the subject of the next section.) Figure 23.11 shows the pop-up window that appears when you click the area within the dashed lines surrounding the image of the Microsoft mouse. The dashed lines appear because Visible was selected as the attribute for the hotspot regions. (Normally you choose Invisible, so the dashed lines don't appear.)

<BR>

<BR>

</OL>

<P><B><A HREF="23vcg11.gif" tppabs="http://202.113.16.101/%7eeb%7e/Database%20Developer's%20Guide%20with%20Visual%20C++%204,%20Second%20Edition/23vcg11.gif">Figure 23.11. The pop-up window displayed when you click the picture of the mouse in the image.</A></B>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -