Dialog Shortcut Consistency Checker

Home
Back To Tips Page

Have you ever had the problem of trying to figure out what caption to use for a control, label, or button because you were running out of letters of the alphabet to underline? And then still get it wrong? Even a small dialog with a number of controls can be a nightmare.

This little utility program, which is written in awk, reads a resource file and for each dialog indicates what letters you have underlined. It can even run as a tool under Visual Studio.

Unlike the Developer Studio "Check Mnemonics" menu item, this gives you a complete picture across all your dialogs. I often print the listings out and use them to cross-check that I've used consistent shortcuts for the same concept in all dialogs. And unlike the "Check Mnemonics", it doesn't stop on the first one, or force you to go past the one you know conflicts to find the next one.

Actually, although the program is little, the downloadable executable is large because it contains the entire awk runtime, which is the only way I can legally redistribute a compiled awk binary. If you have an awk system of your own (there are several public domain versions, as well as a few free downloads around) you should be able to run it. However, I compiled it using Thompson Automation tawk 5.0, and don't guarantee that it will compile or run in other awk systems. If you have a problem and can get around it, let me know and send me the modified source file, and I'll see about integrating it into a more vendor-neutral awk. However, the tawk system is quite nice, comes with a native code compiler, and complete documentation. It is a product I have used for many years (since its original 1.0 release under a different vendor) and I recommend it highly.

For each dialog, it first prints out all the text/captions which have no shortcuts assigned, then for each assigned shortcut letter, prints out the text/captions that are assigned to that letter. A conflict is shown by printing "***" at the start of the line that contains the conflict. This is illustrated below, an excerpt from the listing for one project I did.

--------------------------------------------------------------------------
IDD_TRACE_OPTIONS
C 	"Trace &COM port traffic"
D 	"Master &Debug"
 *** 	"Trace Threa&ds"
F 	"Trace &Finder"
G 	"Lo&g to file"
I 	"Trace &Input"
K 	"Trace Loc&ks"
L 	"&Launch Logger"
M 	"&Memory Check"
O 	"Trace &Output"
Q 	"Trace &Queue operations"
U 	"Trace &Update logic"
W 	"Trace Dynamic &Window Management"

To use it, if you have downloaded the executable, you can type

dialogs whatever.rc

or to get the output stored to a file

dialogs whatever.rc > whatever.lst

If you are using your own awk, the command line will probably look something like the one below, which works with Thompson Automation awk:

myawk -f dialogs.awk whatever.rc > whatever.lst

If you want to add it to VC++ 6.0, go to the Tools menu, choose Customize, use the "New" icon to create a new entry. For the tool name, use something like Dialog Checker. For the executable, type the location where you have put the executable, or the command line you use to activate the awk script. Then for the arguments, use the string

$(FileDir)\$(WkspName).rc

(this assumes that your .rc file has the same name as your workspace, which is typical). Select the option to use an output window. Now you can invoke the checker as a VC++ tool. You will get the output in a window whose tab name is "Dialog Checker" or whatever other name you chose.

The executable is compiled as a standalone tawk executable. If you already have Thomson Automation's tawk compiler or some other awk program, you can just download the source. I use a function 'toupper' which is not part of standard awk, but otherwise I don't think I use anything unusual that other awk variants don't have.

download.gif (1234 bytes)

[Dividing Line Image]

The views expressed in these essays are those of the author, and in no way represent, nor are they endorsed by, Microsoft.

Send mail to newcomer@flounder.com with questions or comments about this web site.
Copyright 1999 The Joseph M. Newcomer Co. All Rights Reserved.
Last modified: May 14, 2011