![]() |
General Programming »
Macros and Add-ins »
DevStudio Add-ins
Advanced
License: The Code Project Open License (CPOL)
Resource ID Organiser Add-In for Visual C++ 5.0/6.0/.NETBy Anna-Jayne MetcalfeAn application/add-in to organise and renumber resource symbol IDs |
VC6, VC7, VC7.1, Windows, MFC, VS.NET2003, VS2005, Dev
|
|
Advanced Search |
|
|
|
||||||||||||||||


(Throughout the article, click on the thumbnails to see larger versions)
A typical MFC or ATL project will contain at least one resource (.RC) file. Associated with each resource file is a symbol definition file - named "resource.h" by default, which contains #define directives for each of the symbols used in the project. Resource symbol definitions are created and modified by the Visual C++ Integrated Development Environment (IDE) when the resources for a project are edited.
Unfortunately, when it does so, it often gets it wrong. How often have you seen this message box whilst editing a dialog?

This happens because two symbols have the same value. The problem is that the IDE is not particularly intelligent at allocating symbol ID values - and does not provide any facilities to unravel the mess that can easily arise as a result. The end result can easily be runtime behavior which is unpredictable to say the least.
The Resource ID Organiser (ResOrg for short) is an Add-in for Visual C++ 5.0, 6.0 and .NET designed to help simplify one of the most annoying - and unnecessary - chores of developing/maintaining Windows applications: maintaining resource symbol IDs.
ResOrg came about when I finally got sick of renumbering resources by hand or using Excel. I was working on a fairly large multi-project application (there were 40 modules at the time), and the difficulty of maintaining the number of resources within the workspace (over 3200!) convinced me to do something about it. Surprisingly, I couldn't find any similar tools to do the same thing, though there are a couple of macros which do something similar, albeit in a much more limited fashion. There are actually three incarnations of ResOrg: a standalone application, a Visual C++5.0/6.0 add-in, and a Visual C++ .NET add-in. Whilst the application is a conventional tabbed MDI application which edits resource symbol files directly, the add-ins integrate with Visual C++ and therefore have direct access to the workspace currently being edited.
ResOrg offers many features to help make managing resource symbol files easier, of which the following are a small selection:
IDR_MAINFRAME) from renumbering operations.
ResOrg allows the resources within a given workspace to be viewed or edited easily. For each project within the workspace, it will allow the symbol definition file (it doesn't have to be called resource.h) to be viewed or edited directly. If (as happens all too often) a symbol file has two or more symbols with the same value, they will be identified as conflicting symbols and displayed in red in the Symbols Display (see the first screenshot).
As you'd expect, individual symbols can be added, edited or removed (be careful with the latter!), but the real power of ResOrg is its ability to detect conflicts and intelligently renumber resource symbols.
The Symbol Properties dialog for a symbol whose value conflicts with another in the same resource symbol file will warn of the conflict, and provides a quick way to resolve it:

The Symbol File Properties dialog allows statistics on the types of symbols in the symbol file to be viewed, and the Next Symbol values easily inspected and corrected:


In large projects, the ability to identify problems can become critical. To that end, ResOrg provides facilities for generating HTML reports showing the symbols in a module - or just those which ResOrg has identified having a problem with their name or value:
If bulk changes are required, the Resource Symbol Renumbering Wizard will guide you through the process of renumbering all of the symbols in a given resource file (click on a thumbnail to see a larger image):
When run, the wizard will identify suitable ranges for the symbols, and renumber them appropriately. Conflicting symbol values can be fixed quickly and easily by this process.
Unfortunately, renumbering some symbols can cause problems. Although the Symbol Renumbering Wizard allows individual symbols to be excluded from renumbering operations, it can be convenient to globally exclude specific symbols (such as IDR_MAINFRAME) from automatic renumbering across any file.
The "Fixed Symbols" page in the Options dialog provides the ability to do this:

Any symbols listed in this page will not be automatically considered for renumbering by the Symbol Renumbering Wizard.
ResOrg.NET is the ResOrg add-in for Visual C++ .NET. As well as a radically different IDE, Visual C++ .NET also introduces a new extensibility model, which allows add-ins much closer integration with the IDE than previous versions.
Unfortunately, this comes at the price of backward compatibility, since the new extensibility model is not backward compatible to previous versions of Visual C++.
For ResOrg, the new model and IDE adds a whole pile of possibilities. In fact, when I started seriously looking at how to approach the IDE, it took me about a month to settle upon a design which was both useful and sufficiently unambitious for my first stab at working with the new IDE!
Although ResOrg.NET does not include a standalone ResOrg app (although it's buildable from the source) and therefore does not have an "Add-In" tab in the Options dialog - it has exactly the same capabilities as ResOrg. It does however add one new bit of UI - a "Tool Window" which shows a summary of the properties of a selected resource symbol file:

From the tool window, you can quickly see whether a symbol file has ID conflicts or if its "Next Symbol" values are in use...and view/modify its properties, or even launch the Symbol Renumbering Wizard. You can of course open the main ResOrg.NET UI to do more in-depth editing or multi-file conflict analysis.
IDE integration is likely to be further improved in subsequent versions, so watch this space!
ResOrg is a fairly complex product, and we try to produce updates as often as we reasonably can. However, releasing new versions is all very well, but how do you let those using the software know that it's been updated?
ResOrg includes several mechanisms to make this process easier (and reduce the number of versions we have to support!):


Note that the update check does not send any information to the server - it merely reads a small text file to determine the latest released product version, and compares that against the version which is currently running. If the running version is older than that reported by the server, the details of the new version will be displayed in the prompt above.
By default, this check occurs every 7 days. This interval can be changed (or version checking disabled entirely) from the "Updates" page of the Options dialog:

ResOrg has its own installer, which will install the necessary files for you. Although it will not configure Visual Studio to load the add-in, the ResOrg application will optionally set up the registry entries needed to configure Visual Studio to do so. Since the installer launches the application by default anyway, this usually happens automatically.
If you need to configure it to do so manually, follow the following steps:
ResOrg.NET has its own (MSI based) installer, which will install the necessary files for you and configure Visual Studio to load the add-in. Once installed, the add-in can be loaded from the Add-In Manager on the Tools menu of the Visual Studio IDE.
When the add-in is loaded, it will re-create its commands and toolbar. You can dock the ResOrg toolbar anywhere convenient or hide it if you prefer.
Note: Unfortunately for add-in authors, the installation of add-ins under Visual Studio .NET is much more complex and fraught than it was under Visual Studio 6.0 * and can cause the IDE to fail to load in certain circumstances. To reduce the risk of this happening, it is highly recommended that you do not install an add-in whilst Visual Studio .NET is running.
* Early indications are that Visual Studio .NET 2005 (Whidbey) is slightly more tolerant than Visual Studio .NET 2002 and 2003, however.
Should you find that Visual Studio .NET refuses to load the add-in, the following sequence of operations should fix it:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.x \AddIns\ResOrgNETAddIn and HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.x \AddIns\ResOrgNETAddIn.
If after doing the above, you still can't get the add-in to load correctly, please contact us and we'll try to investigate further.
In order to function correctly, ResOrg may require several system DLLs to be installed:
The installer includes appropriate copies of mfc42.dll and msvcrt.dll which are installed into the application folder.
ResOrg uses features introduced in the common controls updates shipped with Internet Explorer 5.0. Specifically, it requires version 5.80 of comctl32.dll to be installed. ResOrg will check the version of comctl32.dll upon start-up, and inform you if an update is necessary. You can download an installer (50comupd.exe) for the update from the Microsoft web site.
An appropriate version of Shlwapi.dll is included with Windows 98, NT 4.0 or later versions of Windows. If ResOrg is to be installed on a Windows 95 system which does not have this file, it can be installed by installing Internet Explorer 4 or later.
The ResOrg source includes both the Visual C++ 6.0 workspace and Visual C++ .NET solution. The projects within the two workspaces (to use VC6 terminology) differ slightly, although the core components are common. The projects are:
| Project | Description | VC6.0? | VC.NET? |
|---|---|---|---|
| BXFileDialog | An extension library hosting David Wulf's Office2K style file dialog class and an associated CDocManager class. |
yes |
no |
| CJLibrary | The CodeJock library (no longer freely available I'm afraid) provides the framework for the user interface, including support for the docking projects display and "cool" menus. |
yes |
yes |
| NGLibrary | My own extension library which provides general purpose classes, many of which are from either CodeGuru, CodeProject or MSJ, renamed with a "CNG" prefix for namespacing reasons |
yes |
yes |
| ResOrgAddIn | The Visual C++ 5.0/6.0 add-in (an MFC regular DLL) |
yes |
no |
| ResOrgApp | The standalone ResOrg application |
yes |
yes |
| ResOrgCore | The Core ResOrg module. Most of the useful and interesting stuff lives here! |
yes |
yes |
| ResOrgNETAddIn | The Visual C++ .NET add-in (an MFC regular DLL) |
no |
yes |
| ResOrgNETAddInToolWindows | An ActiveX control DLL used by the Visual C++ .NET add-in to host tool windows within the IDE |
no |
yes |
The ResOrg add-ins are a little unusual in that they are implemented as an MDI application rather than the usual modal dialog or property sheet. To implement this, the mainframe contains a DoModal() method which uses CWnd::RunModalLoop() to create a modal mainframe which performs in a similar manner to its CDialog counterpart. When the add-in is invoked, its main window will appear (starting the modal loop), and the Visual C++ main window will be hidden. When the main window of the add-in is closed (ending the modal loop), Visual C++ will reappear.
Beyond that, their structure is that of a conventional MDI application, save for some additional plumbing to integrate a "workspace" docking window and David Wulf 's Office2K style File Dialogs (the latter in the VC 5.0/6.0 version only).
UI aside, the core of ResOrg is fairly simple: a class (CResourceSymbolManager) which manages a resource symbol file, and a class representing a resource symbol (CResourceSymbol). The add-ins themselves use a helper class (CVc6AutomationHelper or CVc7AutomationHelper as appropriate) to insulate itself from the COM interface of Visual Studio, since I found that doing so makes the code more readable.
The Visual C++ 6.0 workspace has integrated Source Code Control enabled. To open the workspace without access to the SourceSafe database, please run the macro Toggle DevStudio SCC.vbs (in the source code ZIP file) to disable integrated source code control before attempting to load it. You will have to restart Visual Studio for the change to take effect.
CPropertySheetEx and CPropertyPageEx, and the latter just because maintaining two sets of project files is bad enough, let alone three!
As with any project of this nature, there are always a million things that could be done to make it that little bit more useful. Which ones actually get implemented is a matter of luck, judgment, peer-pressure and time!
Some of the major features I hope to add to future versions of ResOrg include:
ResOrg in its current form would not have been possible with the existence of CodeProject, CodeGuru and MSJ. Code from these sources used by ResOrg includes (but isn't limited to):
COXTabWorkspace) by Dundas Software
Thanks are also due to Oz Solomonovich for his excellent WndTabs add-in, which gave me the inspiration to get started on this in the first place...
Please exercise caution when renumbering symbols using ResOrg. Under certain circumstances, doing so can cause problems, which is the last thing I want to happen.
The most significant issues I'm aware of are:
Unfortunately, when you renumber symbols, this is exactly what you want to happen - if you don't rebuild the right files, all sorts of strange behavior can result! If in doubt, clean the affected projects before attempting to rebuild them.
MFC Technical Note TN035: Using Multiple Resource Files and Header Files with Visual C++ - discusses this subject.
Since ResOrg allows you to specify which symbols you want to renumber (and how to do it), you can exclude symbols from the renumbering process if changing their values is likely to cause problems.
A good version control system is invaluable here, since it provides a quick way to review (and throw away if necessary) any changes made. If you haven't got access to one, please back up your resource and resource symbol files before attempting to renumber symbols (WinDiff can be used to review the changes if necessary, but it's a poor substitute I'm afraid).
Ultimately, I hope to add the capability to properly handle resource files (a subject for another article, I think...). Once this is in place, ResOrg will be able to circumvent some of these issues.
Minor update to the article to add details of the automated version checking included within ResOrg, and add troubleshooting information for Visual Studio .NET add-in installation. The code and binaries are unaffected by this update.
ResOrg version 1.6.1 released to CodeProject. This release adds support for Visual C++ .NET 2005.
IDT_xxx) and accelerator (IDK_xxx) symbols.
_APS_NO_MFC" define sometimes found in non-MFC projects. IDR_MAINFRAME) will be excluded from renumbering operations, by default).
ResOrg version 1.5.2 released to CodeProject. This release adds support for Visual C++ .NET 2003.
CResourceSymbolManager object, and calculated when the symbol file is loaded).
TCS_SCROLLOPPOSITE style from the MDI tab control to prevent tabs jumping to the opposite side of the window.
ResOrg version 1.4.5 released to CodeProject. This release marks the debut of ResOrg.NET (thanks to Nick Hodapp of Microsoft for making this possible).
CResourceSymbolBuffer class has now been renamed to CResourceSymbolManager, and the header file parsing/writing code within it moved to a new class (CResourceSymbolFileBuffer). This is more to make the code cleaner than anything else.
ResOrgUtils module to ResOrgCore.
CWorkspaceHelper to CVc6AutomationHelper, and moved it to the ResOrgCore module. Added a corresponding CVc7AutomationHelper class in the ResOrg.NET version.
ResOrg version 1.4.4 released to CodeProject.
#define directives written to resource symbol files to be a closer match to the Visual C++ 6.0 format (better for file differencing).
_APS_3D_CONTROLS value is now written to a resource symbol file only if its value is 1 (i.e. TRUE).
CResOrgVersionCheck::DoThreadFunc() now resets m_pThread and m_hThread to NULL after calling OnDownloadCompleted() - this prevents a continuable exception when running under the debugger on Win2000 systems.
#defines from AfxPriv.h to CJDockContext.cpp in the CodeJock library (the August 2001 Platform SDK broke it).
CRenumWizSelectSymbolsPage::OnWizardBack() now re-enables the "Next" button just in case it was disabled (thanks to Arnt Witteveen for the bug report).
ResOrg version 1.3.10 released:
LVS_SHOWSELALWAYS style so that the selection is retained when it loses the focus.
Removed shlwapi.dll from the installer (it was causing problems on some NT 4.0 systems), and added a ZIP file containing just the binaries. No code changes (yet...).
ResOrg version 1.3.9 first released to CodeProject.
I'd like to take this opportunity to thank all of the developers who have taken the time to either give me feedback or participate in testing, including: Beth Mackenzie (my partner in crimecoding!), Leo Davidson, Gavin Jerman, Penina Weiss, Oz Solomonovich, Jean Palmer, Mustafa Demirhan, Andrew Gebbie, Don Sanders, Bassam Abdul-Baki, Dave Wolfe, John Williams, Glynn Morgan, Andy Greenwood, Martin Palmer, David Wulff and Nick Hodapp (my apologies if I've left anyone out!).
The latest information on ResOrg can be found on the ResOrg website.
Finally, although not a part of the product itself, the Riverblade Developers' Blog (Products, the Universe and Everything) is another way to find out about the current plans for ResOrg, and discuss forthcoming or requested features. (An RSS feed is also included for convenience. If you have any comments, suggestions, bug reports etc., please feel free to contact us, or record your suggestion either here or in a comment on an appropriate post in the blog.)
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 10 Jan 2005 Editor: Smitha Vijayan |
Copyright 2001 by Anna-Jayne Metcalfe Everything else Copyright © CodeProject, 1999-2009 Web17 | Advertise on the Code Project |