How do I specify the condition? In VS 2005 after I right click the resource in resource view, then select "Insert Copy", what should I put in the "condition" field? (CHOICE == CHOICE_ONE) doesn't seem to work, it complains that the condition contains illegal characters.
Last edited by galapogos; April 15th, 2010 at 05:08 AM.
You cannot have a #ifdef conditional inside a stringtable definition, but you can have one around a table.
Code:
#if (CHOICE == CHOICE_ONE)
STRINGTABLE
BEGIN
IDR_MAINFRAME "Main Window Title 1"
END
#elif (CHOICE == CHOICE_TWO)
STRINGTABLE
BEGIN
IDR_MAINFRAME "Main Window Title 2"
END
#elif (CHOICE == CHOICE_THREE)
STRINGTABLE
BEGIN
IDR_MAINFRAME "Main Window Title 3"
END
#endif
Where do I put the preprocessor symbol? If I put it in the .rc or resource.h files, it gets removed once I modify the resource. I've put it in a separate file choice.h, but I'm not sure where to #include it so that the resources see it. I've tried to #include it in the .rc2 file, but that doesn't seem to work.
The only ways I found so far are to:
1. #define the preprocessor symbols in resource.h, but then it gets overwritten when I modify something...
2. Add the symbol in "Project Properties->Resources->General->Preprocesor definitions", but then I have to change this everytime, and it doesn't sync with my choice.h file.
Also, is there any way I can change the executable name based on the preprocessor symbol?
Last edited by galapogos; April 16th, 2010 at 02:23 AM.
Open the resource treeview
rightclick on any part and select the "Resource includes..." item
you'll see a dialog with 2 large edit boxes.
In the top one you'll see see afxres.h being included
add the header file(s) you want
any defines in those headers will now be available for use as resource identifiers.
Let me elaborate my problem. I have a project which is initially in english version, and I need to convert it into spanish language.
So, this is basically what I did:
1. At the resource view, right-click on a dialog box resource, select "Insert Copy".
2. I set the Condition of the new resource as "SPANISH_MODE".
3. The Condition of the original resource is left empty.
4. At the project property pages, I appended "SPANISH_MODE" to the preprocessor definitions.
5. I compiled with no error, but when I run the application, it still load the original dialog box.
Is there anything that I have done wrongly above? Appreciate any help. Thanks.
That's because unless you did something, the original resource will also be in there. And it'll load the original one by default.
Either you have no default at all.
or if you do need it, you need to make sure each resource has it's own unique language id, and explicitely load the resource in the language you want. (MFC doesn't have support for this, so you'll need to call the API functions directly, more annoyingly, this is a terrible hassle for dialogs, formviews etc since the actual resource load is burried inside the MFC internals. Making sure ALL resources of the same ID have a conditional and only ONE version of the conditional is applicable is lots easier.
Thanks guys. I realized I need to specify unique condition for the original resource too. Now it works. Hours of coding have given me headache and overlook this obvious problem.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.