home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / HELPINFO.ZIP / ARTICLE.TXT next >
Text File  |  1994-01-10  |  44KB  |  1,025 lines

  1. CREATING WINDOWS HELP FILES ---------------------------------
  2.  
  3.      Copyright December 1993 by Theodore Kahn. All rights reserved.
  4.      tedkahn@netcom.com
  5.      CIS 70353,2603
  6.      (510) 562-9900
  7.  
  8. ABSTRACT -----------------------------------------------------
  9.  
  10. There are a number of Help Authoring Tools that 
  11. simplify the more mechanical tasks of creating a Help file, 
  12. such as creating topics, making topic jumps, and running the 
  13. Help compiler. However, diagnosing errors (especially the 
  14. nontrivial ones) is still mostly left to you, the 
  15. programmer. Also, claims notwithstanding, Help Authoring 
  16. Tools do not provide access to all features. This article 
  17. fills in these gaps. Specifically:
  18.  
  19. * We concentrate on the most used and needed Help 
  20. features, providing the technical background necessary to 
  21. understand what your Help Authoring Tool is doing, or not 
  22. doing.
  23.  
  24. * We point out problems and errors and offer work-
  25. arounds and alternate solutions.
  26.  
  27. * We provide information about features not contained 
  28. in the Microsoft Help Complier documentation that comes with 
  29. VB.
  30.  
  31. * We include detailed information for integrating the 
  32. Help file with your VB program.
  33.  
  34. * We are making available a companion Help file and VB 
  35. program that illustrates many of the features and ideas 
  36. discussed in this article, and more.
  37.  
  38. While some of this information is specific to Visual Basic programmers, 
  39. the vast majority is applicable to all Help developers.
  40.  
  41.  
  42. THE HELP COMPLIER ---------------------------------------------
  43.  
  44. The Help Complier (a DOS program) is at the center of 
  45. the Help file creation process. It takes as input the Help 
  46. Project File and creates the Help file.
  47.  
  48. There are a number of versions of the Help Complier. 
  49. The one you want (for Windows 3.1) is HC31.EXE Version 
  50. 3.10.504 (extended), or later. This is the version that has been 
  51. shipping with VB Professional. (Note, this is the same identical 
  52. version as the HCP version that ships with the SDK.) Some 
  53. Help Authoring Tools also include the Help Complier. 
  54. However, they may not be the latest version, which can cause 
  55. problems when compiling larger Help files. 
  56.  
  57. If you are using WinWord 6, you will need to get version 
  58. 3.10.505 or later as WinWord 6 RTF files will not work with 
  59. earlier versions of the Help compiler.
  60.  
  61. Below are a few Compiler errors that we found troublesome or had 
  62. difficulty understanding:
  63.  
  64. * Error 1319 Disk Full. Microsoft documentation says 
  65. that this error occurs when the disk the Help file is 
  66. created on is full, which is true. However, this error also 
  67. occurs when the disk referenced by the TEMP environment 
  68. variable is full, which is not documented.
  69.  
  70. * Error 4792. Nonscrolling region defined after 
  71. scrolling region. One or more non-title paragraphs have the 
  72. attribute "Keep with next" set. To quickly find the 
  73. offending paragraphs, (in WinWord), search for this 
  74. attribute being set, and unset it.
  75.  
  76. * Errors 4733, 4753, and 4763. Hidden page break, 
  77. paragraph mark and carriage return, respectively. As in the 
  78. previous error, search for these attributes being set, and 
  79. unset them.
  80.  
  81. *Error 4813. Nonscrolling region crosses page boundary. 
  82. Look for a hard page break where one shouldn't be. Hard page 
  83. breaks should only occur at the end of a topic.
  84.  
  85.  
  86. HELP PROJECT FILE ---------------------------------------------
  87.  
  88. The Help Project file is an ASCII text file that you 
  89. create and edit using an editor (such as Notepad). It 
  90. consists of up to nine sections which either control various 
  91. options or reference files required by your Help file. 
  92. fIGURE 2 shows a sample Help Project File with the six most 
  93. commonly used sections.
  94.  
  95. The [OPTIONS] section is generally pretty straight 
  96. forward. Two things to note:
  97.  
  98. * Be sure and set COMPRESS to False, unless its the 
  99. final release version, then set it to True. There are 
  100. significant differences in both compile times and Help file 
  101. size depending on this option setting.
  102.  
  103. * The documentation doesn't mention the CITATION 
  104. keyword. The text you enter here is automatically included 
  105. in the Copy Dialog Box. Consider using the same text as in 
  106. the COPYRIGHT keyword.
  107.  
  108. The [FILES] section is the only required section. You 
  109. must specify at least one RTF file. You may want to consider 
  110. multiple RTF files for larger Help file projects. As an 
  111. example, each such file could correspond to a different area 
  112. of the program for which the Help file is being written. 
  113. This has two advantages. First, your word processing file 
  114. won't get so large as to be unmanageable. Second, for 
  115. debugging purposes, you can compile only the RTF file of 
  116. interest. To exclude RTF files, precede the file name with a 
  117. semicolon. In this case, you may get warning messages about 
  118. missing topics. Nonetheless, this a good method for 
  119. quickening compile times when you are mostly dealing with 
  120. basic structure and syntax issues.
  121.  
  122. The [BUILDTAGS] section allows you selectively compile 
  123. topics depending on each topics BUILDTAG value. For example, 
  124. suppose you have two versions of your program, regular and 
  125. deluxe. The deluxe version has more options which need their 
  126. own Help topics. You might then set the Build tag Control 
  127. code for deluxe topics to "deluxe" and exclude them from the 
  128. regular version Help file. In this case, you would enter the 
  129. following lines in the BUILDTAGS and OPTIONS sections:
  130.  
  131. [BUILDTAGS]
  132.         deluxe
  133.  
  134. [OPTIONS]
  135.  
  136.     BUILD=~deluxe
  137.  
  138. The tilde (~) character denotes "not." That is, the 
  139. Help file will consist of all topics having Control code 
  140. Build tags other than deluxe, or no Build tag control code. 
  141. (Control codes are discussed in their own section.)
  142.  
  143. The [CONFIG] section is where you but all the Help 
  144. macros that should be executed when the Help file is 
  145. started. A lot of the visual customization of your Help file 
  146. occurs here. This is discussed more fully in the Help 
  147. Compiler Macro section below.
  148.  
  149. The [BITMAPS] section is where you specify the graphics 
  150. files you included "By Reference" in your word processing 
  151. files. Note, the name notwithstanding, you also specify 
  152. .wmf, .shg, and .mrb files here as well. This is discussed 
  153. more fully in the Graphics section below.
  154.  
  155. The [MAP] section is the one place in the entire 
  156. project that connects your VB program to the Help file. 
  157. Specifically, it associates each Help topic (context string) 
  158. to a VB Form or Control HelpContexID property value. You can 
  159. enter the relationships directly, one per line, or reference 
  160. a file. A typical map relationship might look as follows:
  161.  
  162.     Print_dialog_box    60015
  163.  
  164. In this example, the Help file has a topic with a 
  165. context string of "Print_dialog_box." The corresponding VB 
  166. form for which this topic applies would have its 
  167. HelpContexID property value set to 60015. Then, when the 
  168. user presses F1 while print form has the focus, the Help 
  169. File would be invoked and the "Print_dialog_box." topic 
  170. displayed. There are other related issues that are discussed 
  171. in the section "Integrating Help Files with a VB Program."
  172.  
  173. The [ALIAS] section allows you to assign multiple 
  174. context strings to the same topic. You may never need this 
  175. facility, however, if you do, its nice to know it exists. It 
  176. is probably most useful when, after writing the Help file, 
  177. you decide to merge several topics into one. Without an 
  178. ALIAS you would have to change all references to the 
  179. original topics to the merged topics, both in the Help file 
  180. as well as your VB program. Using an ALIAS requires just one 
  181. line in the [ALIAS] section for each topic being merged.
  182.  
  183. The [WINDOWS] section controls various characteristics 
  184. of the window display, such as size, position, and colors. 
  185. Setting the background color of the topic non-scrolling 
  186. region can be a nice visual enhancement. This section is 
  187. required if you intend to have secondary windows, a feature 
  188. many Help files can benefit from. 
  189.  
  190. The [BAGGAGE] section is where you specify multimedia 
  191. files, such as wave files. Unless you know that all your 
  192. users are going to have the necessary hardware to use these 
  193. files, it is best to avoid them.
  194.  
  195.  
  196. THE HELP FILE -------------------------------------------------
  197.  
  198. The Help file (as it appears to you in your word 
  199. processor) consists of a series of topics. Each topic 
  200. contains text and/or graphics which are displayed when the 
  201. topic is selected. A topic also includes one or more codes 
  202. (discussed below) which provide hypertext related 
  203. information. A topic may also contain jumps and Help 
  204. compiler macros (discussed in their own section) which the 
  205. user can execute.
  206.  
  207. There are two types of topics (as it appears to the 
  208. user), regular and popup. It is important to note that the 
  209. difference is not coded into the topic itself, but rather, 
  210. is dependent on the type of jump which caused the topic to be 
  211. displayed.
  212.  
  213. Please note that the order the topics appear in your 
  214. word processor has no bearing on how it appears in the Help 
  215. file. The display of topics in the Help file is dependent on 
  216. how you coded the hypertext control codes and the user 
  217. selection.
  218.  
  219.  
  220. TOPIC ORGANIZATION -------------------------------------------
  221.  
  222. The first paragraph of a topic is, by definition, is the 
  223. topic title. The title can include both text and graphics. 
  224. Usually topics have only one line titles, but this does not 
  225. have to be the case. You could, for example, use a second 
  226. line as a subtitle. You might also consider different fonts, 
  227. sizes, and colors for titles and subtitles. VB help does 
  228. this.
  229.  
  230. A nice touch for many Help files is to make the topic 
  231. title a non-scrolling region. This simply means that as the 
  232. user scrolls through the topic, the title always remains on 
  233. the screen. A further enhancement is to specify a different 
  234. background color for the non-scrolling region. This is done 
  235. in the [WINDOWS] section of the Help Project File. All non-
  236. scrolling regions of a Window must have the same background 
  237. color. The [WINDOWS] section at the bottom of Figure 2 shows 
  238. how to specify a pale yellow non-scrolling region.
  239.  
  240. All paragraphs after the title are considered the body 
  241. of the topic. There is no preset limit to how large a topic 
  242. can be or how many topics a Help file can have.
  243.  
  244. The end of a topic is indicated by a hardpage code 
  245. (Ctrl-Enter in WinWord). The paragraph following a hardpage 
  246. code, would then, by definition, be the title of the next 
  247. topic.
  248.  
  249.  
  250. CONTROL CODES ----------------------------------------------------
  251.  
  252. There are six control codes. Entering these codes and 
  253. specifying the correct information can be the most difficult 
  254. aspect to understanding how a Help file is constructed. This 
  255. is especially true if you don't understand what the 
  256. different hypertext elements do and how they work together.
  257.  
  258. Help Authoring Tools largely take care of the 
  259. mechanical aspects of entering the codes and associated 
  260. information. However, they don't all do them equally well. 
  261. So, when an error occurs (and they will!) or your Help 
  262. Authoring Tool  does not support a feature you want, you 
  263. will have to know what's going on behind the scene to get 
  264. the job done. First, some general information Control codes:
  265.  
  266. * Control codes are indicated by custom footnote 
  267. characters.
  268.  
  269. * Control codes are usually put before the first text or 
  270. graphic of the topic title. 
  271.  
  272. * Four Control codes (#, $, k, +) provide different 
  273. hypertext methods for displaying topics. A topic with no 
  274. codes is possible, but can never be displayed.
  275.  
  276. To insert a custom footnote character in WinWord 
  277. Version 2, choose Insert Footnote and select the Custom 
  278. Footnote Mark option. The character you enter here defines 
  279. the type of Control code you are specifying. Then enter the 
  280. footnote text, which becomes the hypertext information for 
  281. that code. To see and edit the footnotes (in WinWord), 
  282. choose View Page.
  283.  
  284. All Help Authoring Tools perform this task for you in a 
  285. more automated fashion. But we have encountered problems 
  286. where we needed to do this manually to achieve the desired 
  287. effect. Examples include multiline topic titles, mid-topic 
  288. jumps, and mid-topic keyword jumps.
  289.  
  290. The Control code names and associated footnote 
  291. characters are listed below. The first four codes control 
  292. the hypertext nature of the topic.
  293.  
  294. CONTEXT STRING (#)
  295.  
  296. The context string identifies each topic in the Help 
  297. file and must be unique to that topic. That is, no two 
  298. context strings can be the same. The string can be any 
  299. letter (a-z, A-Z), number (0-9), period (.), and underscore 
  300. (_). The string is not case-sensitive and can be up to 255 
  301. characters.
  302.  
  303. Context strings are required if you intend to jump to 
  304. the topic. Generally, all topics are given context strings 
  305. as there is no reason not to and you'll never know if you 
  306. might want to provide a jump to the topic in the future.
  307.  
  308. Topics can have any number of context strings located 
  309. anywhere in the text. This allows you to jump to any part of 
  310. a topic, not just the beginning. This feature is not well 
  311. documented and many Help Authoring Tools do not provide a 
  312. mechanism for coding mid-topic jumps. Nonetheless, many Help 
  313. files could benefit from mid-topic jumps.
  314.  
  315. To see an example of this, run the VB Help and click on 
  316. the Glossary. Then click on the various letters at the top. 
  317. The jumps being executed go to different parts of the same 
  318. topic. The letters are simply hotspots with jumps 
  319. referencing the various context strings in the topic. 
  320. Consider including mid-topic jumps anytime a topic contains 
  321. a lot of text in an ordered fashion. Remember, you can also 
  322. execute mid-topic jumps directly from your application.
  323.  
  324. It is likely that your Help Authoring Tool does not 
  325. support mid-topic jumps, so you'll have to enter them 
  326. manually. This procedure is identical to entering the main 
  327. context string: Move the cursor to the text where you want 
  328. to jump to and insert a # footnote character. Then type the 
  329. context string as the footnote text.
  330.  
  331. TOPIC TITLE ($)
  332.  
  333. The title text is entered using the $ footnote 
  334. character. The text you enter here is displayed in the Goto 
  335. section of the Help Search Dialog Box when a keyword (see 
  336. next section) is selected. This text can be the same or 
  337. different than the title text in the first paragraph. Some 
  338. Help Authoring Tools may not allow you to directly enter 
  339. different text for $ footnote, in which case you will have 
  340. to do so manually. Topics usually include the $ footnote. 
  341. The two exceptions are when:
  342.  
  343. * The topic appears only as a popup or;
  344.  
  345. * The topic appears only in a secondary window.
  346.  
  347. If the $ topic footnote is omitted, you should also not 
  348. insert the k footnote keywords, as the Search Dialog Goto 
  349. list would display ">>Untitled Topic <<".
  350.  
  351. KEYWORDS (K)
  352.  
  353. Keywords are entered using the k footnote character. 
  354. The footnote text contains the keywords, which should have 
  355. the following syntax:
  356.  
  357. * Keywords can include any ANSI character except a 
  358. semicolon.
  359.  
  360. * A semicolon is used to separate multiple keywords.
  361.  
  362. * The maximum length for all keywords is 255 
  363. characters.
  364.  
  365. Keywords work in conjunction with the $ footnote title. 
  366. Therefore, for any particular topic, you would code both $ 
  367. and k Control codes, or neither. Be careful when using 
  368. different forms of a keyword (or phrase) in different 
  369. topics. For example, if in each of four topics you had coded 
  370. "print information", "print dialog box", "printing graphics", and 
  371. "printing documents", the index would contain the four keyword 
  372. phrases, each pointing to its own topic. Its better to code 
  373. the same generic keyword in all four topics. In this case, 
  374. it might be "printing." Now when the user selects "printing" 
  375. from the keyword list the four topic titles appear in the 
  376. Goto list below it.
  377.  
  378. Here is an example of multiple keywords: Suppose you 
  379. had a topic titled "Printing Documents." The two keywords 
  380. might then be "printing" and "document." Note that lower 
  381. case is used as this is an index and that the singular form 
  382. of document is used, not the plural as in the title. Then, 
  383. the word  "document" might also appear in topics titled 
  384. "Opening Documents" and "Saving Documents." 
  385.  
  386. The Keyword footnote does not have to be at the beginning of the 
  387. topic. This is not well know and almost no Help Authoring Tool 
  388. supports it. Place the footnote any where you want. When the user 
  389. selects the topic from the Search Dialog Box, the topic text at the 
  390. keyword footnote is displayed at the top of the Help window. This 
  391. is simular to a mid-topic jump.
  392.  
  393. BROWSE SEQUENCE (+)
  394.  
  395. The browse sequence is entered using the + footnote 
  396. character. The footnote text contains the sequence which is 
  397. composed of two parts: the group name and a sequence number 
  398. separated by a colon (:).
  399.  
  400. The browse sequence provides the user with a quick and 
  401. convenient way to move through topics in an ordered fashion. 
  402. Forward or backward movement is accomplished by clicking the 
  403. browse (>> or <<) buttons on the Help screen (or pressing 
  404. the period or comma keys). As an example, suppose you had 
  405. the following three topics Printing Overview, Print Dialog 
  406. Box, and Print Dialog Box Options. The information goes from 
  407. general to specific, and so follows a natural progression. 
  408. In this case the browse sequences might look as follows:
  409.  
  410. Printing Overview        PRINT:00010
  411. Print Dialog Box        PRINT:00020
  412. Print Dialog Box Options    PRINT:00030
  413.  
  414. Each click of a browse button displays the topic having 
  415. the next higher or lower sequence. When the topic with the 
  416. highest sequence is being displayed, the >> button is 
  417. disabled, conversely, when the topic having the lowest 
  418. sequence is displayed, the << button is disabled. Pressing 
  419. the browse buttons will never jump the user to a topic with 
  420. a different Group Name. If the topic being displayed does 
  421. not have a browse sequence, both buttons are disabled.
  422.  
  423. Some Help Authoring Tools do not provide a direct 
  424. method for changing the Group Name, or do not include a 
  425. group name. This diminishes the browse sequence utility, as 
  426. clicking the browse button displays topics that may or may 
  427. not have related information.
  428.  
  429. Note: In order to make the browse buttons (<< and >>) 
  430. visible you need to add the BrowseButtons() macro to the 
  431. [CONFIG] section of your Help Project File
  432.  
  433. BUILD TAGS (*)
  434.  
  435. A Build tag is added to the topic using the * footnote 
  436. character. This unique identifier allows you to include or 
  437. exclude particular topics from the Help file based on the 
  438. string. See [BUILDTAGS] in the Help Project File section for 
  439. more information.
  440.  
  441. EXECUTE MACRO (!)
  442.  
  443. To execute a macro when the topic is displayed insert the 
  444. ! footnote character before the topic title. This facility 
  445. is not discussed in the Microsoft documentation. By being 
  446. able to execute a macro upon topic display you can customize 
  447. the Help file visual appearance and options on a topic by 
  448. topic basis. At first glance, this appears to be a very 
  449. powerful feature. Unfortunately, there is no corresponding 
  450. method for reverting to the appearance/options in place 
  451. before the topic was displayed. In order to do so you would 
  452. have to put in such a macro in all other topics to which the 
  453. user could jump. And of course, using the Search Dialog Box, 
  454. the can jump to just about all other topics. For this reason, 
  455. this Control code is rarely used.
  456.  
  457. There is one situation is which you might consider 
  458. using it. If you had a "special" topic for which different 
  459. options were applicable, you could disable the Search Dialog 
  460. Box, and History, Bookmark, and Browse buttons, and all 
  461. other means of the user jumping to another topic. You would 
  462. then include in the topic one macro that jumps to the topic 
  463. of your selection. This topic would have ! footnote macro to 
  464. change the Help file options and appearance back to their 
  465. standard form.
  466.  
  467. TEXT FORMATTING
  468.  
  469. Text formatting can be a very frustrating experience 
  470. when creating Help files. While your word processor contains 
  471. a wide variety of features for controlling the visual 
  472. appearance and positioning of the text, the Help Compiler 
  473. supports few of them. In many cases, the compiler simply 
  474. ignores your formatting commands, and in others it will 
  475. generate an error message.
  476.  
  477. CHARACTER FORMATTING
  478.  
  479. You can use any font and point size, but your users 
  480. must also have the font on their machines. Therefore its 
  481. best to stick with fonts that are installed with Windows, 
  482. such as Arial, Courier New, Symbol, and Times New Roman.
  483.  
  484. Bold, underline , italics, and color can be selected, 
  485. super- and subscript cannot. Sometimes subscript can be 
  486. approximated by using a smaller font size. Be careful when 
  487. using color, as users with monochrome screens may find it 
  488. difficult to read, and certainly not pretty.
  489.  
  490. SPECIAL SYMBOLS
  491.  
  492. Windows 3.1 includes the Symbol TrueType font which 
  493. contains Greek alphabet, as well as many other useful 
  494. characters. This font can used just like any other TrueType 
  495. font. However, there is an incompatibility between WinWord 
  496. Version 2 and the Help Complier which leads many people to 
  497. think otherwise. (If you are using another word processor, 
  498. you may not have this problem.) 
  499.  
  500. The logical and straight-forward way to insert a symbol 
  501. is to use the Insert Symbol command. This looks fine in the 
  502. WinWord file, but the character will not display in the Help 
  503. file. Instead, select the Symbol TrueType font from the font 
  504. list box; then enter the character. There is one further 
  505. issue, many of the characters do not map to a standard 
  506. keyboard character. In these cases, you must enter the 
  507. character by turning keyboard NumLock on, pressing the Alt 
  508. key and entering the four digit code (be sure and enter 
  509. leading zeros). Use the Character Map program that comes 
  510. with Windows to find the character codes. 
  511.  
  512. PARAGRAPH FORMATTING
  513.  
  514. Paragraphs can be left, centered, and right justified, 
  515. but not full justified. When Help text is displayed, lines 
  516. are automatically wrapped at word boundaries to fit the 
  517. window width. If you want text lines to always break at the 
  518. same place in the line, enter a line break at the end of 
  519. each line, as you want it to appear in the Help file (Shift-
  520. Enter in WinWord). Then, select the "keep lines together" 
  521. paragraph format attribute. (This attribute keeps a 
  522. paragraph on one page.)
  523.  
  524. TABLES
  525.  
  526. Tables are the best way for working with columnar 
  527. formatting. You cannot, however, apply any line or shading 
  528. attributes to the table, such as cell boarders. Your only 
  529. choice is to apply paragraph borders. To add paragraph 
  530. borders (in WinWord) for text inside a table, select one or 
  531. more characters in the paragraph and then select the Format 
  532. Boarder Dialog Box. If you do not select the characters, the 
  533. Border Dialog Box applies to the Table cells, not the 
  534. paragraph. This causes Help Compiler error 4652, Table 
  535. formatting too complex. Also, remember you can include 
  536. graphics in the table cells.
  537.  
  538. There are some other formatting features relating to tables 
  539. that are discussed in the Microsoft Help Authoring Guide (see 
  540. the sidebar Additional Information on how to get this guide 
  541. at no charge.) 
  542.  
  543. POPUP TOPICS
  544.  
  545. As we already mentioned, topics appearing in a popup 
  546. window are really no different than other topics. It only 
  547. means that a popup macro (or jump) was used to jump to the topic. 
  548. However, as a general rule, topics displayed only as popups 
  549. do not have entries in the Search Dialog Box or a browse 
  550. sequence (Control codes $, k, and +). They do, however, have 
  551. to have a context string (Control code #) so that the jump 
  552. to the topic can be made.
  553.  
  554. The popup window width is a function of the screen and 
  555. Help window sizes. This can cause them to become very wide. 
  556. To make the popup window have a constant size, manually 
  557. insert line breaks where you want them and select the 
  558. paragraph attribute "keep lines together." See Paragraph 
  559. Formatting for more information. Another alternative is put 
  560. the text inside a one cell table.
  561.  
  562. IMPORTANT: The title paragraph of pop-up topics should NOT 
  563. have the "Keep with next" attribute set. If it is set, the 
  564. remaining paragraphs in the topic are not displayed (and 
  565. there is no error message).
  566.  
  567. The "Keep with next" attribute indicates that the topic is to 
  568. have a non-scrolling title region. Some Help Authoring Tools 
  569. use one style for all topic titles. In this case, specifying a 
  570. non-scrolling region causes the "Keep with next" attribute 
  571. to be set for popups, which results in popup topic text not 
  572. displaying.
  573.  
  574. GRAPHICS ----------------------------------------------------
  575.  
  576. The Help Compiler supports four types of graphics 
  577. files: bitmaps (BMP), windows metafiles (WMF), hypergraphic 
  578. (SHG), and multiple-resolution bitmaps (MRB). The latter two 
  579. formats are special formats that can only be used by the 
  580. Help Complier. The programs to create SHG and MRB files are 
  581. included with VB professional.
  582.  
  583. INSERTING GRAPHICS FILES
  584.  
  585. BMP and WMF files can be put directly into your word 
  586. processing file, at the position where they are to appear. 
  587. However, the preferred method is to insert them "by-
  588. reference." SHG and MRB files can only be inserted by-
  589. reference. To insert a graphic "by reference":
  590.  
  591. 1. In your word processing document you need to enter 
  592. {bmX filename} where X is L for a left justified graphic, C 
  593. for a character and R for a right justified graphic. 
  594. (WinWord users note: this is not a field code as the braces 
  595. would otherwise indicate.)
  596.  
  597. 2. In your Help Project file [BITMAPS] section add a 
  598. line referencing the file. Note, if the bitmap file is located 
  599. in the project directory or a bitmap root directory, you
  600. don't need to include a specific reference in the HPJ file.
  601.  
  602. A graphics file is specified only once in the [BITMAPS] 
  603. section, no matter how many times it is referenced in the 
  604. word processing document (Step 1).
  605.  
  606. Inserting graphics by-reference leads to a smaller Help 
  607. file, especially when the same graphic is referenced 
  608. multiple times.
  609.  
  610. CREATING HYPERGRAPHICS FILES
  611.  
  612. SHG files are BMP or WMF files that have been processed 
  613. by the hotspot editor (SHED.EXE). SHED allows you to define 
  614. hotspots (rectangular regions) to a BMP or WMF file. A macro 
  615. (such as a jump macro) is then assigned to each hotspot. 
  616. When the SHG graphic is displayed in the Help file and the 
  617. cursor is positioned over a hotspot, the cursor changes to a 
  618. hand. This indicates to the user that clicking the mouse 
  619. initiates the macro, such as jumping to another topic.
  620.  
  621. Make sure you are using SHED Version 3.50.784 or 
  622. latter. This version has a new feature in the Edit menu 
  623. called Replace. Documentation on how to use SHED can be 
  624. found in the Microsoft Help manual and the SHED Help file. 
  625. However, neither document contains information on Replace, 
  626. so here's what it does.
  627.  
  628. Suppose you had created a SHG file with 10 hotspots, 
  629. each with a different macro. Now, your colleague responsible 
  630. for creating the original BMP file comes up to you and says 
  631. she has newer version with better colors. Here's how you'd 
  632. handle it using Replace:
  633.  
  634. 1) Start SHED and open up the SHG file having the 10 
  635. hotspots. 
  636.  
  637. 2) Start a graphics program that can read BMP files 
  638. (such as PaintBrush) and open up the new BMP file.
  639.  
  640. 3) Copy the BMP file to the Clipboard.
  641.  
  642. 4) Go back to SHED and select Edit Replace.
  643.  
  644. The new graphic image replaces the graphic image in the 
  645. shg file, leaving the hotspots in place, along with their 
  646. macros. If the hotspot positions did not change there is 
  647. nothing left to do but save the new version. Otherwise, you 
  648. have to move the hotspots to their new correct regions, 
  649. which is a very easy task. Then save the file.
  650.  
  651. CREATING MULTIPLE-RESOLUTION BITMAP FILES
  652.  
  653. Bitmap graphics do not scale easily to different 
  654. resolutions from the one that created them. The Multiple 
  655. Resolution Bitmap Compiler (MRBC) allows you to create the 
  656. dame bitmap image under different resolutions and puts them 
  657. together into one file. The WINHELP.EXE will then use the 
  658. version that best matches the screen resolution at the time. 
  659. If your application is not intended to run under CGA and EGA 
  660. resolutions then will not likely need to bother with this 
  661. step
  662.  
  663. Consider using Windows Metafiles whenever possible. 
  664. They don't have resolution scaling problems and can also be 
  665. much smaller.
  666.  
  667. MACROS
  668.  
  669. Macros (which can also be thought of as programming 
  670. statements) greatly extend the intrinsic Help Complier 
  671. capabilities. The first thing to realize is that macros can 
  672. be started in six different ways:
  673.  
  674. 1) When the Help file is started. These macros are put 
  675. in the [CONFIG] section of your Help Project file.
  676.  
  677. 2) Double underlined text or graphic hotspot. The jump 
  678. or macro follows directly after the underlined text, is 
  679. marked hidden, and (if a macro) is preceded by an 
  680. explanation point.
  681.  
  682. 3) Hypergraphic hotspot. Hotspots are created using 
  683. SHED.EXE. Each hotspot is assigned its own jump or macro.
  684.  
  685. 4) When a topic is displayed. The macro is put into the 
  686. ! footnote text.
  687.  
  688. 5) When menu items or buttons at the top of the Help 
  689. screen are selected.
  690.  
  691. 6) By your VB program. Use the WinHelp function and 
  692. pass the macro as a parameter.
  693.  
  694. MACRO SYNTAX
  695.  
  696. Pay close attention to the syntax when writing macros, 
  697. as the error message you are most likely to get is "Syntax 
  698. error in macro..." When you get this message, check for 
  699. unbalanced parentheses and quotation marks, and commas in 
  700. the right places. Also make sure that open and close quotes 
  701. are used in the correct place. Remember, they must be used 
  702. with nested strings.
  703.  
  704. * The general syntax is MacroName(`parameter1', 
  705. `parameter2',...)
  706.  
  707. * Macros can be nested.
  708.  
  709. * Macros can be executed sequentially by separating 
  710. them with semicolons. In some cases, when the macros are 
  711. executed from the Help Project file, you may need to use a 
  712. colon, as the semicolon is used for indicating comments. I
  713. have not seen the colon documented anywhere.
  714.  
  715. * String parameters must be enclosed in a single open 
  716. and single close quotation marks. Double quote marks can 
  717. also be used.
  718.  
  719. * Nested strings must be enclosed using the single open 
  720. and single close quotation marks.
  721.  
  722. * Note, the single open quotation is often found with 
  723. the tilde (~) key and the single close quotation is found 
  724. with the double quotation mark. They are not the same 
  725. characters.
  726.  
  727. * To include the above syntax characters in a string, 
  728. precede the character with a backslash (\).
  729.  
  730.  
  731. EXAMPLE -----------------------------------------------------
  732.  
  733. Jumping to a secondary window is probably the most 
  734. commonly used macro. In this example we show how to execute 
  735. the macro from three different places: the Help file, the 
  736. Help Project File, and your VB application. In all cases, 
  737. the name of the Help file is "myapp.hlp," the secondary 
  738. window is called "glossary." and the context-string of the 
  739. topic being jumped to is "g_topic." (Note, in order to jump 
  740. to a secondary window, you it must have been defined in the 
  741. [WINDOWS] section of the Help Project File.)
  742.  
  743. The name of the jump macro we will use is JumpId. Its 
  744. general syntax is
  745.  
  746.     JumpID(`filename>windowname', `context-string')
  747.  
  748. This macro jumps to a topic based on its context 
  749. string. A similar macro, JumpContext, jumps to a topic based 
  750. on its context number. The ">" character separates the two 
  751. parts of the parameter. The >windowname is optional if you 
  752. not jumping to a different window and the filename is 
  753. optional if you are not jumping to a different Help file, 
  754. therefore a null string is acceptable. However, if you are 
  755. jumping to a different window, the filename must always be 
  756. specified, whether or not the topic is in a different Help 
  757. file. Substituting our values into the above syntax, we 
  758. have:
  759.  
  760.     JumpID(`myapp.hlp>glossary', `g_topic')
  761.  
  762. To use this macro in a Help file, precede it with and 
  763. explanation point (!) and format it and macro as hidden 
  764. text. Then format text or graphic preceding !macro as double 
  765. underlined to indicate to the user that clicking the 
  766. text/graphic causes an action  to occur (macro to execute).
  767.  
  768. Because this type of jump is so common, the Help 
  769. Complier supports a second, simpler syntax for jumping to 
  770. topics:
  771.  
  772.     context-string>windowname@filename
  773.  
  774. You only need to specify the >windowname or @filename 
  775. if you are jumping to a different window or Help file. As 
  776. above, format this text as hidden and precede it with double 
  777. underlined formatted text or graphics. Note, you do not need 
  778. the explanation point. This form also works for hotspot 
  779. jumps created by SHED. 
  780.  
  781. While these simpler forms work fine for jumps initiated 
  782. within the Help file, they cannot be used from the Help 
  783. Project File or from your VB program. In either of these 
  784. cases, you will need to use the JumpID macro.
  785.  
  786. Next, we show how to create a button on the main Help 
  787. button-bar to execute the jump macro. First, because we want 
  788. the button available when the Help file starts (that is, not 
  789. to be dependent on the topic being displayed), the macro 
  790. should be put in the [CONFIG] section of the Help Project 
  791. File. The general syntax is :
  792.  
  793.     CreateButton("button-id", "button-label", "button-macro")
  794.  
  795. The button-id gives you a method for referencing the 
  796. button in other macros; the button-label is the text 
  797. displayed on the button; and the button-macro is the macro 
  798. string that is to be executed when the button is clicked. 
  799. Our CreateButton macro might look as follows:
  800.  
  801. CreateButton("g_button", "&Glossary", "JumpID(`myapp.hlp>glossary',`g_topic')")
  802.  
  803. Notice the single quotes in the JumpId macro above, in 
  804. this case double quotes generates a syntax error.
  805.  
  806. Executing Help macros from your VB program involves 
  807. passing the macro string as a parameter to the WinHelp 
  808. function. This is discussed in detail in the next section.
  809.  
  810. INTEGRATING THE HELP FILE INTO YOUR VB PROGRAM ----------------------------
  811.  
  812. There are two distinctly different methods for 
  813. integrating the Help file into your VB program. The first 
  814. method, which is largely built-in to VB, provides context-
  815. sensitive help. If, however, you want to include a Help menu 
  816. item, or execute Help macros from within your program, you 
  817. will need to use the WinHelp API.
  818.  
  819. In either case, the first thing you need to do is 
  820. specify the name of the help file. By convention it usually 
  821. has the same name as the exe file, but with a hlp extension. 
  822. The easiest way to set the file name is at design time: 
  823. Select Options Project from the menu and enter the file name 
  824. into the box labeled Help file. From then on (in design or 
  825. exe modes) the method App.HelpFile returns the specified 
  826. help file.
  827.  
  828. CONTEXT SENSITIVE HELP
  829.  
  830. Forms and controls (that can receive the focus) have a 
  831. property called HelpContextID. This value is associated with 
  832. a specific Help topic using the context string. The 
  833. associations are made in the Help Project File [MAP] 
  834. section. When the user presses F1, the Help topic for the 
  835. control (or Form) having the focus is displayed.
  836.  
  837. If the control (having the focus) HelpContextID has not 
  838. been set, then the Help topic for the controls container is 
  839. used, and so on. When no Control or Form HelpContextID has 
  840. been set, the Contents Help topic is displayed.
  841.  
  842. For example, suppose a form has a picture box 
  843. containing two command buttons. The HelpContextID values 
  844. are: Button1 = 1 and Picture = 2. Button2's HelpContextID 
  845. has not been set. When Button1 has the focus then its Help 
  846. topic is used. However, when Button2 has the focus, the 
  847. Picture control Help topic is displayed.
  848.  
  849. One source of confusion here is that the Microsoft 
  850. documentation uses inconsistent terminology: The VB manuals 
  851. refer to HelpContextID whereas the Help Compiler uses the 
  852. term context number, they are the same.
  853.  
  854. Also, remember that you can change the HelpContextID 
  855. programatically. This might be useful in situations where 
  856. the selection of certain option(s) changes the availability 
  857. of other options. In these situations, you could have 
  858. multiple Help topics for the same control, each specific to 
  859. a different option set. Using the WinHelp API opens up many 
  860. other possibilities for customizing not only the text, but 
  861. how its presented to the user.
  862.  
  863. THE WINHELP API
  864.  
  865. Included with every copy of Windows is a program called 
  866. WINHELP.EXE. This program is used by all applications to 
  867. display help files complied by the Help Complier. The 
  868. WinHelp function allows you to send instructions to 
  869. WINHELP.EXE for performing a variety of tasks. Examples 
  870. include: displaying topics that may not be associated with a 
  871. specific control, bringing up the Search Dialog Box, and 
  872. closing the Help file when your application ends. Knowing 
  873. how to use the WinHelp functions can significantly increase 
  874. your programs usability. Figure 6 shows the required WinHelp 
  875. declarations which need to be included in your application, 
  876. and four routines that illustrate typical help usage.
  877.  
  878. In essence, the WinHelp function provides a mechanism 
  879. for accessing Help Compiler macros from within your program. 
  880. There are, of course, issues that need special handling. 
  881. Figure 6 address two common ones.
  882.  
  883. Displaying the Search Dialog Box. Some programs provide 
  884. direct access to the Help Search Dialog Box from the Help 
  885. menu. If you look through the Help macros you would find 
  886. Search(), which indeed performs exactly that task. Using 
  887. Search(), the WinHelp function would look as follows:
  888.  
  889. r = WinHelp(frmMain.hWnd, App.HelpFile, HELP_COMMAND, `Search()')
  890.  
  891. This function invokes the Help file, displays the 
  892. Contents topic and brings up the Search Dialog Box. A better 
  893. way, not mentioned in the Help Compiler documentation, is to 
  894. use HELP_PARTIALKEY and pass a null string. When this function 
  895. executes, the Search Dialog Box is displayed over your 
  896. program. Then, when the user selects the topic the Help file 
  897. is brought up at that topic, bypassing the Contents topic 
  898. altogether. This in fact is the way VB Help works. 
  899.  
  900. Displaying secondary windows. Before a secondary window 
  901. can be displayed, the main window must be available. This is 
  902. done by using the HELP_FORCEFILE command. (See Figure 6, Sub 
  903. mnuHelpGlossary_Click.) If you don't want the main window 
  904. displayed, add the following statement at the end of the 
  905. routine:
  906.  
  907. r = WinHelp(frmMain.hWnd, App.HelpFile, HELP_COMMAND, "CloseWindow(`main')")
  908.  
  909. Displaying popup topics. The HELP_POPUPID function 
  910. displays a topic in a popup window. However, there is a bug 
  911. that causes the focus to be lost, so for now it is best to 
  912. avoid using it.  There are Shareware programs available for 
  913. providing balloon-type help. (See Sidebar XXX.)
  914.  
  915. Summary. Most programs will only use a few WinHelp 
  916. functions. Nonetheless, using them at the right time and 
  917. place can make big difference, with very little programming. 
  918. For example, two other things you can easily change are the 
  919. Contents topic ([HELP_SETCONTENTS]) and the Help file. You 
  920. might consider these changes if the help information is 
  921. dependent on user controlled options or data. Finally, for 
  922. those so inclined, you can write your own DLL's to access 
  923. custom macros. See the enclosed VB program for more detailes.
  924.  
  925.  
  926. SIDEBAR: ADDITIONAL INFORMATION
  927.  
  928. The Microsoft Help Compiler documentation that comes 
  929. with VB Professional is very terse, and for the beginner, 
  930. difficult to understand. Even worse, its incomplete. Below 
  931. is a short list of places to look for additional information 
  932. to supplement what Microsoft provides.
  933.  
  934. * If you have VB professional, the HC subdirectory 
  935. contains all the programs necessary to create a Help file 
  936. (except a word processor), additional documentation relating 
  937. to API calls, and a sample project (ICONWRKS).
  938.  
  939. * We highly recommend the book Developing Online Help 
  940. for Windows, Scott Boggan, etal., Sams Publishing 1993. 
  941. (800-428-5331, $39) This covers everything from writing 
  942. styles for Help files to a spreadsheet to project its 
  943. development cost. It also includes a disk with a number of 
  944. sample Help files that illustrate various features. The disk 
  945. also has a simple Help Authoring Tool (macros for WinWord 
  946. Version 2).
  947.  
  948. * The Help Authoring Guide. This is a Help file created 
  949. by Microsoft (possibly as a precursor to a more comprehensive 
  950. help document). It contains far more information than the 
  951. manual that comes with VB. Its available on CompuServe in the 
  952. WinSDK forum, Lib 16 as file HAG.ZIP. This a highly technical 
  953. document, most people would be better served getting Boggan's book.
  954.  
  955. * Check out the sample Help file and VB program included with
  956. this article. They illustrate many of the issues and features 
  957. discussed here, and a lot more. 
  958.  
  959.  
  960. SIDEBAR: HELP AUTHORING TOOLS
  961.  
  962. Even if you are only going to write a small Help file, 
  963. you should look into getting a Help Authoring Tool of some 
  964. sort. Coding Help topics is just too tedious to do manually. 
  965. (Remember, Developing Online Help for Windows mentioned 
  966. above includes a basic Help Authoring Tool for WinWord 2.) 
  967.  
  968. A Help Authoring Tool can be as simple as a few macros 
  969. that automate Control code insertion, or complete stand-
  970. alone programs that include custom text editors and 
  971. facilities for manipulating the Help Project File. They 
  972. range in price from nothing to $500. While its generally 
  973. true that the higher priced offering provide more features, 
  974. that's not always the case. More important, you may not need 
  975. or use the additional features.
  976.  
  977. There are two types of Help Authoring Tools. The first 
  978. type provide their own editor for you to enter topic text. 
  979. These products tend to be more self-contained and somewhat 
  980. easier to use, since the vendor can control all aspects of 
  981. the process. The downside is that the text editors tend to 
  982. be limited, at least when compared to a full-featured word 
  983. processor. For example, you may not be able to define all 
  984. the paragraph formats the exactly as you want, or the editor 
  985. may not contain a spell-checker, glossary or macro features 
  986. you've grown accustomed to.
  987.  
  988. The second type of Help Authoring Tool uses a word 
  989. processor for text editing and provide macros for automating 
  990. the topic coding process. Many of these types of products 
  991. also include mechanisms for running the Help Compiler from 
  992. within the word processor. Most use WinWord. There are, 
  993. however, products available for AmiPro and WordPerfect and 
  994. perhaps other word processors. Check with the vendor, user 
  995. support groups, or online forums for more information.
  996.  
  997. If you already have and use WinWord, then a Help 
  998. Authoring Tool that uses it would be a reasonable choice. 
  999. After all, do you really need to learn another word 
  1000. processor?
  1001.  
  1002. One further note: I have yet to find a Help Authoring 
  1003. Tool which uses its own editor and that supports all the 
  1004. Help Compiler features. The most glaring missing feature is 
  1005. the lack of support for tables. Nor do these products 
  1006. provide any reasonable work-arounds. That is, you cannot 
  1007. insert a table manually. For this reason, I would not 
  1008. recommend these products for any serious project.
  1009.  
  1010. There a number of good shareware products that may meet your 
  1011. needs. Look for them in the WinSDK forum on CompuServe. The 
  1012. one I like is CreateHelp ($40, CompuServe 100111,3452). If 
  1013. you're in the market for a commerical product, and support is 
  1014. important, try HelpBreeze (Solutionsoft, $279, (408) 736-1431).
  1015.  
  1016. One thing to remember is that people create help files for 
  1017. different reasons and have different technical backgrounds. 
  1018. Online documetation is the obvious reason for creating a Help 
  1019. file. However increasingly, standard printed documents, such 
  1020. as procedures manuals, are being converted to Help files. 
  1021. Different Help Authoring Tools reflect these various needs and 
  1022. skills.
  1023.  
  1024.  
  1025.