views:

166

answers:

1

I'm trying to create an About box for my Windows C++ application. In Visual Studio 2008, I'm using the dialog editor to design the dialog. I want the About box to display the application's version in a static label.

I can hardcode the version into the dialog, stored in a .rc file, but then I'll have to remember to update the version in multiple places.

My application version is #defined in version.h as APPLICATION_VERSION. The resource editor can be convinced to put

#include "version.h"

at the top of the .rc file, so I have access to the APPLICATION_VERSION symbol.

However, I cannot use this symbol from the dialog editor. I can edit the .rc file by hand, replacing the hardcoded version string by the symbol APPLICATION_VERSION. That works fine until I edit the dialog in the dialog editor again: upon saving the .rc from the dialog editor, the symbol gets overwritten with its current value.

Of course, I can set the version label to some dummy text, overriding that text when I receive WM_INITDIALOG, but that feels very clunky and unnecessary. Is there any other workaround that allows me to keep the application version in a single place?

A: 

The way I do this is to put the resource in a separate file with a .rc2 extension, and #include that into the .rc file (like you're doing with your version.h). I then edit the .rc2 files with a normal text editor, not the Visual Studio resource editor.

That system's not too bad for VERSIONINFO resources, which is what I use it for, but I can see it would be more of a pain for dialog resources. I'd love to hear of a better way, but I don't know of one.

RichieHindle
As a matter of fact, I'm having the same problem with my VERSIONINFO resources. But those are indeed easy enough to edit by hand, so as long as I don't touch the resource editor for those, I'm fine.
Thomas