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: May 6, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT While you likely have very good reasons for remaining on WinXP after end of support -- an estimated 20-30% of worldwide devices still are -- the bottom line is your security risk is now significant. In the absence of security patches, attackers will certainly turn their attention to this new opportunity. Join Lumension Vice President Paul Zimski in this one-hour webcast to discuss risk and, more importantly, 5 pragmatic risk mitigation techniques …

  • Ever-increasing workloads and the challenge of containing costs leave companies conflicted by the need for increased processing capacity while limiting physical expansion. Migration to HP's new generation of increased-density rack-and-blade servers can address growing demands for compute capacity while reducing costly sprawl. Sponsored by: HP and Intel® Xeon® processors Intel, the Intel logo, and Xeon Inside are trademarks of Intel Corporation in the U.S. and/or other countries. HP is the sponsor …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds