Visual Studio - opening RES files like other files

On 28/11/2013 at 18:19, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R13-R14 
Platform:   Windows  ;   
Language(s) :     C++  ;

When I double click CPP, STR, and H files, they immediately open up in the code editor.
But RES files behave different, Visual Studio of course think they are real RES files, which need special treatment. So Visual Studio will stubbornly open the resource editor (or at least the Resource View), when these files are double-clicked in the Solution Explorer.

I think it is unfortunate that Maxon has used the RES extension for the description files. RES has a special meaning in Windows, but the Maxon RES counterparts are plain simple pure text files. Had Maxon used the extension RS, all would have been fine. RS files are text files, telling the Windows Resource Compiler how to compile RES files, and as such fit the bill exactly.

As it is now, in Visual Studio I have to right-click the RES file, then select "Open With", then select (I have set it to default) Source Code Editor, and then additionally click the OK button.

All these unnecessary actions, just to open a RES file, are getting on my nerves.
Does any of you VS users know of a way to make Visual Studio open RES files directly in the Code Editor? Is there a way to make my life easier?

On 29/11/2013 at 04:32, xxxxxxxx wrote:

Tools > Options > Text Editor > File Extensions. Add a res entry.

On 29/11/2013 at 07:10, xxxxxxxx wrote:

Hi Katachi,

Originally posted by xxxxxxxx

Tools > Options > Text Editor > File Extensions. Add a res entry.

Been there, done that, doesn't help.
What application do you assign the RES extension to?

On 01/12/2013 at 10:16, xxxxxxxx wrote:

I do what Katachi said with .cu (cuda) and it works fine

you need a restart to visual studio to take effect "they appear in project like normal .cpp files"

On 02/12/2013 at 03:52, xxxxxxxx wrote:

I think the problem that both of you are not realizing is that .res is the extension used by VS for Windows project Resource files.  Adding the extension still causes the file in the project, when double-clicked, to open as a project Resource file and not a C4D resource text file in the source editor.  This is *built into* Visual Studio.  So, how do you circumvent that?  I tried the File Extensions thing and my .res file opened as a Windows project Resource in Resource View.  No way around it but to right click and "open with".

On 02/12/2013 at 06:50, xxxxxxxx wrote:

@kuroyume0161 yes that's true , I have tested it now and it needs a right click open with

On 02/12/2013 at 14:05, xxxxxxxx wrote:

Originally posted by xxxxxxxx

I think the problem that both of you are not realizing is that .res is the extension used by VS for Windows project Resource files.

I hope that does not include me, :) because that is what I tried to explain in my initial post.
I have found the solution:
I have moved the entire plugin project to another drive. I always develop and work on another drive than the operating system. But for C4D and out of pure laziness, I was developing on C:, in the C4D's plugin folder.

So, I moved the whole shebang to drive Q:, where I have my other software projects.
What I do then, is to employ a simple DOS batch file, which I have added to the Post Build Event. So for every build, this batch file copies all files over to the appropriate plugins folder on C:

Here is the trick:
I have renamed all RES files to RS. Then they open directly as any other text file, when double clicked. The batch file not only copies the RS files, it also renames them to the correct RES type! All of this happens so fast, that I can run and debug as before, by pressing F5 in VS 2010.
This has been an enormous relief, because opening those RES files got on my nerves, to say the least..

Here is the DOS batch file, for those who may want to try. In fact, I wonder why I did not do this before, I normally do not keep any work on C:, only the OS and all my applications. Now it feels much better. Especially because right now I need to edit the RES files all the time.

@echo off
set SOURCEROOT=Q:\Software\C4D\MySuperPlugin\nset DESTROOT=C:\Program Files\MAXON\CINEMA 4D R14\plugins\MySuperPlugin\n  
copy "%SOURCEROOT%*.cdl*" "%DESTROOT%*.cdl*" /y
xcopy "%SOURCEROOT%res\*.h" "%DESTROOT%res\*.h" /s /y
xcopy "%SOURCEROOT%res\*.tif" "%DESTROOT%res\*.tif" /s /y
xcopy "%SOURCEROOT%res\*.str" "%DESTROOT%res\*.str" /s /y
xcopy "%SOURCEROOT%res\*.res" "%DESTROOT%res\*.res" /s /y
xcopy "%SOURCEROOT%res\*.rs" "%DESTROOT%res\*.res" /s /y


On 03/12/2013 at 04:53, xxxxxxxx wrote:

I too do all of my projects from a separate 'Data' drive and use the Post Build Event to copy the plugin and other files to my C4D install and launch C4D for testing of the changes.

That is an interesting solution.  In my case, it would require some caution since I do contract work as well (currently even) and pass the source and res folders to the contractor.  Either I would need to copy the files and rename the .rs to .res or the contractor would need to be aware of that usage.

On 03/12/2013 at 05:17, xxxxxxxx wrote:

It can be further refined, by clearing the archive flag on all files, so that only changed files (they get the archive flag set, automatically by Windows when saved again) are copied over.
And then xcopy can check the archive flag. I did that many years ago, when backing up to floppies.

On 03/12/2013 at 09:58, xxxxxxxx wrote:

8" floppies?

On 03/12/2013 at 10:28, xxxxxxxx wrote:

No, I started with Windows 3.11 ;)

On 03/12/2013 at 13:14, xxxxxxxx wrote:

Originally posted by xxxxxxxx

No, I started with Windows 3.11 ;)

A veritable stripling. I was coding in 6502 assembly language on an Atari 800 30 years ago...

(Now sit back and watch lots of others beat that!)


On 03/12/2013 at 13:46, xxxxxxxx wrote:

Yes :)
As a matter of fact, I have programmed in assembler. I used Delphi's built in BASM, and also MASM. Stuff was written in assembler because a) I was a pervert and liked it, b) it turned out it ran much faster, we had some graphic operations, and compiled in a high level language, they ran just too slow.
Those days size also was important. I wrote a DLL which was 900 bytes"big", in assembler. Would have been impossible in other languages, AFAIK.

Somehow I got a kick out of writing assembler, the control and hands on feeling you get, almost touching the CPU with your hands.. I had shelves of computer books, sadly I had to trash a lot of them. But I will never throw the assembler books, although they will most likely never be put to any use..

On 04/12/2013 at 02:20, xxxxxxxx wrote:

Started on a Commodore 64 with 5.25" floppies doing BASIC and 6510 Assembler about 30 years ago myself.  Moved to Amiga then MSDOS in the early 1990s.  Actually wrote a multi-window GUI for MSDOS through the graphics interface (VGA and maybe SVGA back then).

Yes, MASM.  Remember Borland?

On 04/12/2013 at 02:45, xxxxxxxx wrote:

Yes we wrote a lot from scratch, programming was handicraft, now it is more or less industrialized. Imagine, I even wrote the installer for the software from scratch, pure Windows  API. It occupied a mere 4 Kb on the 1.4 Mb floppy.
Borland - I remember Borland very well. I attended 4 of their Conferences, Philadelphia, San Diego, Long Beach and San Jose. Was an adventure, for me coming from Norway! Used Borland products many years. Even their TASM compiler (Turbo Assembler). I programmed in Borland Delphi many years, and still do! But Borland is far away, Embarcadero now has Delphi and C++ Builder etc.