Strings to Resources
This page describes how to use the Strings to Resources converter. The source code and executable can be found on the software page.
This program modifies the source files to you programs. You are recommended to backup your source code prior to using this program, or to use the confirm option and the backup option.
Controls
Directory. Specify the directory to be scanned for files to convert. Either type the directory name or use the Windows file dialog.
- Include subdirectories. Select this if you want the converter to convert files that are in subdirectories of the specified directory.
- C/C++ (.c.cpp.cxx). Select this if you want to convert code in source files.
- C/C++ (.h.hpp.hxx). Select this if you want to convert code in header files.
- Confirm changes. Select this if you want to check if each change should be made.
- Make backup. Select this if you want a backup made of each file that is modified. Backups have the .bak extension, so a modified example.cpp will have a backup file of example.cpp.bak.
- Comment changed lines. Select this if you want a comment inserted in the code at each point where a code change is made.
- Update resource file. Select this if you want to update the resource (*.rc) file.
- Update header file. Select this if you want to update the header (resource.h) file.
- do LoadString(IDS_). Select this if you want to insert CString.LoadString() calls to load CStrings from the resource file.
- don't change sprintf. Select this if you do not want text supplied to sprintf() to be modified.
- don't change arrays. Select this if you do not want text in string arrays modified.
- don't change filespec. Select this if you do want text that is a file specification modified.
Resource file. Specify the resource file to be used for this conversion (typically projectName.rc). Either type the directory name or use the Windows file dialog.
Header file. Specify the header file to be used for this conversion (typically resource.h). Either type the directory name or use the Windows file dialog.
Examine. Examine the list of changes that have been made.
Scan. Scan the files to find out how many potential changes there are.
Convert. Scan the files and convert the files according to the controls.
Close. Close the program.
When the files are being converted, if the confirm option is enabled a confirmation dialog is displayed. The dialog displays some source code before and after the line to convert to provide context. The line to convert has a ==> symbol at the start of the line.
- Replace. Replace the quotes with _T(""), move to the next change.
- Don't Replace. Move to the next change without replacing the quotes.
- Replace All In File. Replace all the remaining quotes with _T(""), then move to the next file.
- Don't Replace Any In File. Move to the next file without making any more changes in this file.
- Replace In All Files. Replace all the remaining quotes with _T("") in this file and all remaining files.
- Don't Replace In Any File. Stop replacing quotes in this file. Do not make changes in any more files.
Important Notes
This program replaces _T("string") with a reference to a CString. The CString will be declared earlier in the function where the string was originally declared. The CString will be given an autogenerated name based partly on the text of the string and partly on the resource ID assigned to the string when the string was added to the resource file and the header file.
Some strings are defined outside of functions and thus the replacement CString and its associated LoadString(IDS_???) call are defined outside of functions. Such code will not compile. You may need to edit some or all of the converted files to move code that references such CStrings into functions, or create initialisation functions that should be called when the program is started or when a dialog is created, etc.
Occasionally the parser will also place CStrings just before a function definition rather than in the function. This doesn't happen often, but will need to be edited to fix this.
If CStrings are assigned in a loop, or the function the CStrings are loaded in (using LoadString()) is in a loop you will suffer performance penalties due to LoadString(). You may need to identify such functions and restructure your code appropriately. For general user interface work however such changes are unlikely to be necessary.
As always with programs that modify source code, backup your work before proceeding. Object Media will not be held responsible for any loss incurred by using this program. You use this program at your own risk.

