Link to home
Start Free TrialLog in
Avatar of mrwad99
mrwad99Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Visual studio mangles resource file: is prevention possible ?

Ah hello.

I have a resource file, that contains several #if defined statements.  The purpose of these is simply to only provide certain functionality if a symbol is defined.

For example,

#if defined (_LIMITED_FEATURE)
            MENUITEM "Limited Feature.",                ID_FILE_LIMITED_FEATURE
#endif

But I find that occasionally visual studio will remove all my #if defined statements (meaning all menu items are available regardless of any symbol I may define), which is a total pain.  Is there any way I can prevent it doing this ?  I have been advised it is something to do with the macro APSTUDIO_INVOKED, but Googling only brings back other people's resource files: not useful.

TIA
SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
A further point (you have probably considered) is the whole design concept.
I prefer that the end user (paying customer?) sees that some functionality that is only available in the version they pay <more> for (advertising in a word ! ).  
If there is a good reason that some functionality should be hidden then I find code easier to maintain if the mechanism to hide is in one location not a bit in the resource editor, another bit in the header and in a further two/three places in the cpp file.  (MessageMap, OnCommand, OnUpdateCommand).  Yes it is fractionally larger, yes it takes 0.01 seconds longer to launch.  If it is a huge ammount of code to hide then it could be in a dll and only invoked with LoadLibrary, GetProcAddress so the exe has little extra code in it.
Avatar of mrwad99

ASKER

Thanks for those suggestions all; Radu's one was ultimately the easiest so was accepted as the solution.

Cheers.