Help RTF files from Resource RC Files

Environment: VC6

I had just about completed a medium-sized project with quite a few dialogs and menus in it, and it was time to start writing help files. Yuk! I still use WinHelp-based help, partly because I like it, and partly because MFC supplies transparent F1 help, but being an impoverished cheapskate academic I haven't got a commercial help generator. This meant facing several days of wrestling with WinWord in RTF format, and I knew from experience that I was going to be bored stiff and make lots of typing errors in creating the links.

Being infinitely distractable, I decided that it would be be worth spending some time writing a topic generator that could read my RC file and create skeleton RTF files for the menus and dialogs. The program "Help RC" is the result.

The program parses the selected RC file looking for dialogs, menu items and string resources associated with menu IDs (the menu prompts). It takes rather a brute-force approach to the parsing, just looking for the appropriate keyword headers in the RC file (it skips the DESIGNINFO section). It stores dialog and menu captions, and the menu prompts in Maps, with the ID as the key. I used maps because I wanted to eliminate duplicate menu items with the same ID occurring on different menus. It then iterates through the dialog and menu maps, passing the dialogs and menu items to list boxes for sorting and display.

The program can write 3 types of RTF help file. The "Dlg RTF" button writes out a file where each dialog has a separate page, with the dialog caption as a title line, and the ID (with 'H' prepended) as the #-footnote. Keyword and title footnotes are also written, with the caption as the text. The "Menu RTF" button does a similar job, but each page represents a particular menu item (duplicates are eliminated).

The "Menu Tab" button is a bit different. It writes out a separate page for each top-level popup menu in each menu resource. The page shows a table with each menu item on a different row. The first column shows the menu title (sub-menu items are prepended by the sub-menu popup caption), while the second column shows the prompt extracted from the string table with the same ID as the menu item. The overall result is like the various menu pages of the default file "Afxcore.rtf" generated by the framework. The only tricky bit of the "Menu Tab" option is dealing with sub-menus. To do this the program parses the RC file again, and has a simple stack-like response to sub-menus (popups within popups). It stores the caption of the sub-menu, and prepends it to the caption of the actual menu item.

I don't claim to be any expert in RTF format - I 'stole' code from Word-generated files, and whittled it down by experiment to what appears to be the essentials to get the display I wanted. Neither do I claim that the RC parsing-bit is bullet-proof. However, it's worked OK so far on my files, and saved me quite a bit of time, so I offer the program in the hope that it may also be useful to other people.

Downloads

Download demo project - 21 Kb


Comments

  • As the author says, a very handy little tool.

    Posted by TroubleShooter on 03/12/2004 12:57pm

    Thanks.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As everyone scrambles to protect customers and consumers from the Heartbleed virus, there will be a variety of mitigating solutions offered up to address this pesky bug. There are a variety of points within the data path where solutions could be put into place to mitigate this (and similar) vulnerabilities and customers must choose the most strategic point in the network at which to deploy their selected mitigation. Read this white paper to learn the ins and outs of mitigating the risk of Heartbleed and the …

  • Live Event Date: September 19, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT In response to the rising number of data breaches and the regulatory and legal impact that can occur as a result of these incidents, leading analysts at Forrester Research have developed five important design principles that will help security professionals reduce their attack surface and mitigate vulnerabilities. Check out this upcoming eSeminar and join Chris Sherman of Forrester Research to learn how to deal with the influx of new device …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds