Updated: 1/22/2004; 8:07:53 PM.
ronpih I guess...
Your guess is as good as mine...
        

Saturday, April 05, 2003

Creating Stand-alone Resource Files in VS .NET

If you work with Win32 resources you may have noticed that there is no way to create .rc files in Visual Studio .NET outside the context of a project (you could do this in VC6 and earlier).  The short explanation for this is that the VS IDE is architected in a way that when you create new stand-alone files (via File\New\File, for example), you can only create a single physical file.  .rc files require a companion resource.h file and thus don't fit this model.  In the VS7.0 development cycle, the resource editor developers tried hard to figure out a way to fit the resource editor model into the VS IDE model but couldn't come up with a reasonable way to do it.  (Project Wizards are able to do this because the new project model is designed to create multiple files simultaneously.)

If you need to create a stand-alone .rc file, there is a trick you can use that, while it isn't as easy as just creating the file in the IDE, can save you some time and is less error prone than typing it all in by hand.  Here's what to do:

  1. Create a new text file with the name you want your .rc file to have ("test.rc", for example).  The contents of the file should be a single line that looks like this:

    #include <afxres.h>
  2. Open the file in the VS IDE.
  3. Add a resource (or resources) to the file via the normal means.
  4. Close the file and elect to save.  You will get a message box that says something like:

    The resource script c:mydirectorytest.rc was not created using Microsoft Visual Studio.  Comments, macros, preprocessor directives, and conditionally included information may be modified and/or removed from this file during the build process.  Replace existing file?
  5. Say Yes.
  6. You now have your stand-alone .rc file with all the header file TEXTINCLUDE stuff, code page defines, etc. set up (and VS .NET has also created its companion resource.h file as well).

 


12:19:59 AM    comment []

© Copyright 2004 Ronald Pihlgren.
 
April 2003
Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      
Mar   May

Weblogs
Microsoft Testers
VC++ Bloggers
Links
Note:This is a personal weblog. All opinions expressed here are mine alone.


Click here to visit the Radio UserLand website.

Subscribe to "ronpih I guess..." in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.