I'm using VS 2003 and C++. I added a form to a project and then removed it,
but now I want to put it back in the project. How can I do this? Simply
adding the files (.cpp, .h, and resource file) does not work... I can no
longer use the designer on the form. I don't want to reconstruct the form
from scratch.
There doesn't seem to be any way to "add an existing item" where the item is
a form.
I think this is the same problem I would face if I wanted to add a form from
a different project into this one. It would seem this should be easy - and
should not require turning the form into an assembly that is deployed as a
separate file.
Any suggestions would be appreciated!
Wed. Sep. 01, 2004 9:10 PM PT
If you use add existing item, to add your project files, .cpp, .h, and
.resx, then visual studio will add them into the solution, but .resX file
will be in Resources, where as it should be under your .h file, and also it
will not show the form icon. Also, if you compile and link your project with
.resX file in to the resources folder, then you may get compile error. If
you remove the .resX file, and just compile your project will compile, link,
and run successfully. But still you can not do any changes in to your form
.resX. The solution to this problem is.....
First make a backup of your .vcproj file. Then, copy this file, with
extention, .XML, because your project file is just an XML file.
Open this file in a good editor, you can use the same VSIDE also. Scroll
down to the secition, "Header files". Make sure before doing this, you have
added your project files, .cpp source, and .h header files.
Now check your form file, location, and add few lines, exactly as it is
required. I am pasting a section of my header files.
=========== start ====================
<File
RelativePath=".\frmMain.h"
FileType="3">
<File
RelativePath=".\frmMain.resX">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCManagedResourceCompilerTool"
ResourceFileName="$(IntDir)/NWindClient.frmMain.resources"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCManagedResourceCompilerTool"
ResourceFileName="$(IntDir)/NWindClient.frmMain.resources"/>
</FileConfiguration>
</File>
</File>
============end ====================
My form name header file is frmMain.h, and resource file is frmMain.resX
Note, the FileType, attribute for header file, this is 3 for Form file, and
4 for UserControl, This file type enumeration/ values you can get from the
MSDN library. Make sure you type exactly as it is, because single mistake
will not load your project. Once this is done copy this .XML file into your
project directory, and rename it to .vcproj. Try loading it. This works at
my place, perfectly. If you have any questions send it to me.
There is no simple way other than this.
Good Luck.
> I'm using VS 2003 and C++. I added a form to a project and then removed it,
> but now I want to put it back in the project. How can I do this? Simply
[quoted text clipped - 11 lines]
>
> Any suggestions would be appreciated!