Click here to Skip to main content
13,895,532 members
Click here to Skip to main content
Add your own
alternative version


35 bookmarked
Posted 9 Jul 2004

Resource Comparer

, 23 Aug 2004
Rate this:
Please Sign up or sign in to vote.
Compares two .RC-files and shows important differences. Useful if you create programs in multiple languages.

Sample Image - rcomparer.gif


I have been using the resource editor in Visual C++ for a while to create programs in multiple languages. It works great and is very easy to use. But it is quite hard to keep all languages synchronized. For example, if you upgrade your program and add a control, you will probably need to add it in other languages as well. This is easy, if you remember to do it :-). To solve this, I created a tool that compares two resource-files (.rc) and notices if something doesn't look right (like missing controls, different window styles...).

Using the program

RC is quite straightforward to use. Select the two files you want to compare, and click on Compare. After a couple of seconds is the comparing done and you see the result. If you have resources in multiple languages in a file and just want to read a specific language, write the language string in the language boxes (like LANG_ENGLISH for English). Leave this empty if you want to read all languages.

In the bottom of the window are error messages if the program fails to parse the files. Detected languages will also be found here.

Another feature of the program is that it could extract all strings from a file. This is very useful if you want to spell check your program, just click on "Make string list" and copy the log to a word processor. Only "File 1" will be used in this function.

If you want to see all resources in "File 1", click on "Make resource tree". If you uncheck "Only IDs", then you will also see all settings that the program has found (like strings, style of controls).

The fourth button, "Translation table", creates a table where you see how strings are translated. If you check "LocalizeRC INI", the output will be written as an INI-file to use with LocalizeRC (another program at CodeProject).

What it checks

Resource Comparer checks these:

  • Menus
    • Strings
    • Settings (Checked, Grayed...)
    • Structure (Order of items)
  • Toolbars
    • Structure
  • Dialogs
    • Captions
    • Style settings (Border, system menu...)
    • Extended style settings (Tool windows, client edge...)
    • Tab order
  • Controls
    • Strings
    • Type (So controls with same ID are of the same type)
    • Style settings
    • Extended style settings
    • Help ID
  • Strings
    • %-words
    • \-characters
  • Bitmaps
  • Icons
  • Cursors

The program does not check:

  • Accelerators
  • Version
  • Data (strings) in combo boxes
  • Size of bitmaps, toolbars, icons or cursors.

Note: The program will fail to parse the file if you are using condition settings on the resources.


Checking strings could be very important. The program gives you five methods to use:

  1. None:

    Don't check strings.

  2. Check %-words

    Let's say you have a string like this: "Your name is: %s". You use this string with CString::Format to replace "%s" with the user name. Then it is very important that in all other languages, the string also includes "%s". If it's not, then your program will probably crash when it runs CString::Format. Therefore, check the program that all strings have the same number and order of %-words. So, if you have a string like "%s, %d" in one file, and another string like "%d, %s" in a second file, then you will get an error message.

  3. Check \-characters

    This is very similar to (2). Let's say you have a string like this: "Hello\nworld". Then you translate it, and make a little error: "Hello\world" (no, they are not the same - look again!). It is very easy to make mistakes like that; I have done it myself several times. But now, I have this program that will warn me if I do it again :-).

  4. %- and \- problems

    Uses both test 2 and test 3.

  5. Compare full string

    This checks if strings match completely. This is useful if you want to see what changes you have done from an old version.

All strings are running this test, also string in dialogs and menus.


As a programmer, I know that it is more interesting to look on an example than reading a manual, so let us look on a log:

Comparing menus:
    Comparing menu resource: IDR_MAINFRAME
        Different style in ID: ID_FILE_CHECKED (1: CHECKED, 2: )
        Different menu structure. Item 4 is ID_FILE_SAVE in 1, 
                                          and ID_FILE_SAVE_AS in 2
        Different menu structure. Item 5 is ID_FILE_SAVE_AS in 1, 
                                             and ID_FILE_SAVE in 2

Comparing toolbars:
    Comparing toolbar resource: IDR_TOOLBAR1
        Different toolbar structure. Item 1 is ID_FILE_NEW in 1, 
                                             and ID_FILE_SAVE in 2
        Different toolbar structure. Item 2 is ID_FILE_SAVE in 1, 
                                              and ID_FILE_NEW in 2

Comparing dialogs:
    Comparing dialog resource: IDD_ABOUTBOX
        String error in IDOK: Different number of %-signs ('OK', 'OK - %s')
    Comparing dialog resource: IDD_TEST_DIALOG
        Dialog style doesn't match ( DS_MODALFRAME|WS_POPUP|
        Different style settings on control ID: IDC_LISTCONTROL 
                           (1: 'LVS_REPORT|WS_BORDER|WS_TABSTOP', 
                           2: 'LVS_REPORT|LVS_OWNERDRAWFIXED|
        Couldn't find control ID: IDC_STATIC_EXTRA
        Different items count (6 in 1, 5 in 2)

Comparing strings:
    String error in IDS_TOFORMAT: Different %-words (%s and %d)
    String error in IDS_SLASH: Different number of \-signs 
                         ('Hello\r\nworld.', 'Hello\r\\world.')
    String error in IDS_ULTRA: Different %-words (%s and %d), 
                             Different \-characters (\r and \n)

Comparing bitmaps:
    Couldn't find bitmap: IDB_BITMAP_EXTRA in file 2

Comparing icons:
    Couldn't find icon: IDI_ICON_EXTRA in file 2

Comparing cursors:
    Couldn't find cursor: IDC_CURSOR_EXTRA in file 2

As you can see, we have checked menus, toolbars, dialogs, strings, bitmaps, icons, and cursors. In the menu section, we see that in one of the files, one menu item is checked, in the other it's not. Two menu items also have swapped places.

In the toolbar section, the buttons ID_FILE_NEW and ID_FILE_SAVE have swapped places.

In the dialogs, there are several errors. The button IDOK in the about box has a percent sign in the second file, but in the first, there is none. In the other dialog, we see that the dialog has different styles in the two files. The list has the "Owner draw" value in the first file, but not in the second. We are also missing a control in the second file, IDC_STATIC_EXTRA. Therefore, we do not have the same number of controls in the two files.

We have problems with three strings. In IDS_TOFORMAT, we are using "%s" in the first file, and "%d" in the second. In the string IDS_SLASH, there is a misspelling, \\ should be \n. In the last, we have a string that has both types of errors.

We also see that we are missing a bitmap, icon, and a cursor in the second file.

Points of Interest

There is a special ID you can use to have multiple number of items with the same ID, IDC_STATIC (this is the default ID for new static text controls). When Resource Comparer compares dialog controls, it compares items with the same ID. So when more than one control has the same ID, we have a problem. Resource Comparer solves this by using the tab order to figure out how to match the controls. The first control with IDC_STATIC will be compared with the first control with the same ID in the other file. And the second control will be compared with the second control in the other file, and so on.

If you look at the code, you may see that I have written it quite fast. But it seems to work well and is enough for me. Parsing the resource files was the hardest thing to do. The program makes a lot of assumptions but it seems to be clever enough :-). As I said before, conditions are not supported. When you use conditions, #if statements are added in the file, and I haven't cared about this. But if you are interested to solve this problem, just go for it :-). And I know the output could be better, but since I will not use this program very often, I really don't care about this.

Unicode is supported, but not multi-byte characters in ANSI.

I have only tested this program on projects made in VC6, but I don't think there should be any problems with later versions.

Links and Miscellaneous



  • 21 August, 2004 - Version 1.2. Support for Unicode. Applied a minor fix by Graham Pye. Captions in dialogs are now tested.
  • 4 August, 2004 - Version 1.1. "Help ID" is now checked on controls. Controls with ID IDC_STATIC are now compared. If more than one control has this ID, the tab order will be used to figure out how to match them. The program can now create INI files to use with RC Localization Tool
  • 10 July, 2004 - Initial version.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Sweden Sweden
PEK is one of the millions of programmers that sometimes program so hard that he forgets how to sleep (this is especially true when he has more important things to do). He thinks that there are not enough donuts in the world. He likes when his programs works as they should do, but dislikes when his programs is more clever than he is.

You may also be interested in...

Comments and Discussions

QuestionExcellent! Pin
Member 31967695-Jul-17 6:01
memberMember 31967695-Jul-17 6:01 
GeneralProblem with new resources Pin
Sunil Apte3-Sep-10 1:18
memberSunil Apte3-Sep-10 1:18 
GeneralMore checking please Pin
-273C22-Oct-06 22:43
member-273C22-Oct-06 22:43 
GeneralText Fits Checker Pin
Rob Hudson13-Jun-05 5:57
memberRob Hudson13-Jun-05 5:57 
GeneralRe: Text Fits Checker Pin
GrahamPye10-Aug-05 13:38
memberGrahamPye10-Aug-05 13:38 
GeneralRe: Text Fits Checker Pin
Rob Hudson10-Aug-05 22:20
memberRob Hudson10-Aug-05 22:20 
GeneralCompare the two RC and push the difference to the localized RC Pin
jchen80003-Mar-05 18:43
memberjchen80003-Mar-05 18:43 
GeneralRe: Compare the two RC and push the difference to the localized RC Pin
PEK4-Mar-05 7:49
memberPEK4-Mar-05 7:49 
General"" parsed as \" Pin
Gemini_II24-Aug-04 23:27
memberGemini_II24-Aug-04 23:27 
GeneralRe: "" parsed as \" Pin
PEK26-Aug-04 10:11
memberPEK26-Aug-04 10:11 
GeneralRe: "" parsed as \" [modified] Pin
ardjand10-May-07 22:19
memberardjand10-May-07 22:19 
GeneralExcellent Pin
.dan.g.24-Aug-04 14:10
professional.dan.g.24-Aug-04 14:10 
GeneralRe: Excellent Pin
PEK26-Aug-04 10:23
memberPEK26-Aug-04 10:23 
GrahamPye18-Aug-04 0:42
memberGrahamPye18-Aug-04 0:42 
PEK18-Aug-04 1:28
memberPEK18-Aug-04 1:28 
QuestionUnicode support? Pin
prcarp9-Aug-04 5:18
memberprcarp9-Aug-04 5:18 
AnswerRe: Unicode support? Pin
PEK9-Aug-04 22:46
memberPEK9-Aug-04 22:46 
GeneralRe: Unicode support? Pin
GrahamPye17-Aug-04 0:49
memberGrahamPye17-Aug-04 0:49 
GeneralRe: Unicode support? Pin
PEK17-Aug-04 23:43
memberPEK17-Aug-04 23:43 
GeneralRe: Unicode support? Pin
GrahamPye18-Aug-04 0:32
memberGrahamPye18-Aug-04 0:32 
GeneralRe: Unicode support? Pin
PEK18-Aug-04 1:23
memberPEK18-Aug-04 1:23 
GeneralAmazing! Pin
Obliterator9-Aug-04 1:06
memberObliterator9-Aug-04 1:06 
GeneralRe: Amazing! Pin
PEK9-Aug-04 2:33
memberPEK9-Aug-04 2:33 
GeneralResource IDs may not be unique Pin
Mathieu Jacques14-Jul-04 7:04
memberMathieu Jacques14-Jul-04 7:04 
GeneralRe: Resource IDs may not be unique Pin
PEK15-Jul-04 0:57
memberPEK15-Jul-04 0:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.190306.1 | Last Updated 24 Aug 2004
Article Copyright 2004 by PEK
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid