Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / IDE / September 2004

Tip: Looking for answers? Try searching our database.

How to  re-use form code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Strommen - 02 Sep 2004 02:21 GMT
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!
Lord2702 - 02 Sep 2004 05:31 GMT
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!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.