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

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • VMware vCloud® Government Service provided by Carpathia® is an enterprise-class hybrid cloud service that delivers the tried and tested VMware capabilities widely used by government organizations today, with the added security and compliance assurance of FedRAMP authorization. The hybrid cloud is becoming more and more prevalent – in fact, nearly three-fourths of large enterprises expect to have hybrid deployments by 2015, according to a recent Gartner analyst report. Learn about the benefits of …

Most Popular Programming Stories

More for Developers

RSS Feeds