Can anyone provide an explanation or a link that explains how exactly a STRINGTABLE in a MFC resource file is defined and can be manually expanded?
I tried to do it, but failed to do so in a multi project solution. Most projects in said solution have their own resource files and renamed resource.h-files.
When the application tries to access the string resources, the error message 'Resource string for '22392' not found' shows up. 22392 is the ID of the string I tried to create. I don't get a similar error message if I use an already defined string ID instead.
Using the Visual Studio 2010's wizard to add a string resource didn't work either. But it shows up correctly in the listing of resource symbols and in the string table editor.
Needless to say that I haven't participated in the creation of this solution.
Thanks for your help.
[EDIT1]
I excluded the possibility of conflict by performing a ‘find in files’ for the value used and using other values as well: 22390, 22391, 22393, 22394, 22395. Always got the same result.
[EDIT2]
I repeated the steps I did in the complex solution in a new, clean and simple MFC application with one project and it worked without problems. Therefore I assume my problem is related to the fact that the solution has multiple projects and resources.
The steps were the following:
- Pick a free number in the resource.h (which is named differently in my case) and add a #define IDS_XXX free number.
- Validate the chosen number by performing a ‘find in files’ with it.
Add a line to a STRINGTABLE in resource.h, preferably close to a IDS_ with a value close to the one I picked.
STRINGTABLE BEGIN IDS_OTHER "I have a number close to XXX" IDS_XXX "HelloHello" END
Access the string in the application:
CString strMyString; strMyString.LoadString(IDS_XXX); AfxMessageBox(strMyString, MB_YESNO | MB_ICONEXCLAMATION);
[EDIT3]
I tried to locate the call of LoadString that causes the error message. The LoadString that fails to load my string resource is located in a class, that is in the same project as the resource file (.rc) containing said string resource. The error message 'Resource string for '22392' not found' is generated there. That explains at least why I found nothing googeling it.
[EDIT4]
I could isolate the cause further.
In cstringt.h hInst is NULL aka the string ressource can't be found:
_Check_return_ BOOL LoadString(_In_ UINT nID)
{
HINSTANCE hInst = StringTraits::FindStringResourceInstance( nID );
if( hInst == NULL )
{
return( FALSE ); // goes here, but shouldn't, hInst == NULL
}
return( LoadString( hInst, nID ) );
}
This is strange since it is possible to access another string ressource within the same resource file just fine.