How to import a dialog resource from one project to another project by using Visual C++ .NET or Visual C++ 2005 (829437)
The information in this article applies to:
- Microsoft Visual C++ 2005 Express Edition
- Microsoft Visual C++ .NET (2003)
- Microsoft Visual C++ .NET (2002)
SUMMARYThis step-by-step article describes how to import a dialog
resource from a resource file or from a resource template of a Microsoft Visual
C++ .NET project to another Visual C++ .NET project or from a resource template of a Microsoft Visual
C++ 2005 project to another Visual C++ 2005 project. This article
also describes how to create a dialog resource-based project by using the Windows
Forms Application template and the MFC Application template from where a
resource can be copied. This article also describes two different techniques to
copy a resource from one project to another project. Back to the topRequirementsThis
article assumes that you are familiar with the following topics:
- Programming with Visual C++ .NET or Visual C++ 2005
- Resource files
Back to the topCreate dialog-based applications in Visual C++ .NET or in Visual C++ 2005In Visual C++ .NET 2003 or in Visual C++ 2005, you can create dialog-based applications
by using either the MFC Application project template or the Windows Forms
Application project template. In Visual C++ .NET 2002, you can create
dialog-based applications by using the MFC Application project
template. To create a dialog-based application by using the Windows
Forms Application project template in Visual C++ .NET 2003 or in Visual C++ 2005, follow these
steps:
- Start Microsoft Visual Studio .NET 2003 or Microsoft Visual Studio 2005.
- On the File menu, point to
New, and then click Project.
- Click Visual C++ Projects under
Project Types, and then click Windows Forms
Application (.NET) under Templates.
Note In Visual Studio 2005, click Visual C++ under
Project Types, and then click Windows Forms
Application under Templates. - In the Name text box, type
DialogApp, and then click OK. By
default, the Form1 form is created.
- In Solution Explorer, click the Resource
View tab.
- In Resource View, expand the DialogApp
node.
- Right-click the app.rc folder, and then
click Add Resource.
- In the Add Resource dialog box, expand
Dialog under Resource Type.
- Click IDD_FORMVIEW [English (U.S.)], and
then click New. A new dialog resource is added to the project
and is opened in Design View.
Note In Visual Studio 2005, click IDD_FORMVIEW. - Right-click the dialog template, and then click
Properties.
- Change the ID property to IDD_MY_FORMVIEW.
- Add a Button control to the dialog template.
- Press the CTRL+SHIFT+S key combination to save all
files.
- On the File menu, click Close
Solution to close the solution.
- Exit Visual Studio .NET 2003 or Visual Studio 2005.
To create a dialog-based application by using the MFC
Application project template in either Visual C++ .NET 2003, Visual C++ .NET
2002, or Visual Studio 2005, follow these steps:
- Start Microsoft Visual Studio .NET or Visual Studio 2005.
- On the File menu, point to
New, and then click Project.
- Click Visual C++ Projects under
Project Types, and then click MFC Application
under Templates.
Note In Visual Studio 2005, click Visual C++ under
Project Types, and then click MFC Application
under Templates. - In the Name text box, type
DialogApp, and then click
OK.
- In the MFC Application Wizard - DialogApp
dialog box, click Application Type.
- Under Application type, click to select
Dialog based, and then click
Finish.
- In Solution Explorer, click the Resource
View tab.
- In Resource View, expand the DialogApp
node.
- Right-click the DialogApp.rc folder, and
then click Add Resource.
- In the Add Resource dialog box, expand
Dialog under Resource Type.
- Click IDD_FORMVIEW [English (U.S.)], and
then click New. A new dialog resource is added to the project
and is opened in Design View.
Note In Visual Studio 2005, click IDD_FORMVIEW. - Right-click the dialog template, and then click
Properties.
- Change the ID property to IDD_MY_FORMVIEW.
- Add a Button control to the dialog template.
- Press the CTRL+SHIFT+S key combination to save all
files.
- On the File menu, click Close
Solution to close the solution.
- Exit Visual Studio .NET or Visual Studio 2005.
Back to the topCopy a dialog
resourceTo copy a dialog resource from a resource file of a Visual C++
.NET or Visual C++ 2005 project to a resource file of another Visual C++ .NET or Visual C++ 2005 project, follow
these steps. Note A resource file has an .rc extension.
- Start Visual Studio .NET or Visual Studio 2005.
- On the File menu, point to
Open, and then click File.
- Locate the source resource file.
- Click the resource file, and then click
Open to open the file.
- Perform steps 2 through 4 for the destination resource
file.
- To switch to the source resource file, click the tab that
contains the file name of this file.
- Expand the folder that has the same name as the file name
of the source resource file.
- Expand the Dialog folder.
- Right-click the dialog resource that you want to copy, and
then click Copy.
- To switch to the destination resource file, click the tab
that contains the file name of this file.
- Right-click the folder that has the same name as the file
name of the destination resource file, and then click Paste.
The dialog resource appears in the Dialog folder of the target
resource file.
- Press the CTRL+SHIFT+S key combination to save all
files.
- On the File menu, click Close
Solution to close the solution.
Back to the topUse a resource
templateTo import a dialog resource from a resource template file of a
Visual C++ .NET project to another project, follow these steps:
- Start Visual Studio .NET or Visual Studio 2005.
- On the File menu, point to
Open, and then click File.
- Locate the source resource file.
- Click the resource file, and then click
Open to open the file.
- On the File menu, click Save
FileName As.
Note FileName is a placeholder for the file
name of the resource file. - To save the resource file as a resource template file,
select Resource Template (*.rct) in the Save as
type list, and then click Save.
- On the File menu, click
Close to close the resource file.
- On the File menu, click Open
Solution.
- In the Open Solution dialog box, locate
the target project to where you must copy the dialog resource file.
- Click the solution file, and then click
Open.
- In Solution Explorer, right-click
ProjectName, and then click
Properties.
NoteProjectName is a placeholder for the
name of the project that you opened. - In the ProjectName
Property Pages dialog box that appears, expand the
Configuration Properties folder, and then click the
Resources folder.
- Click the ellipsis button (...) next to the value for the Additional Include
Directories property. The Additional Include
Directories dialog box appears.
- Click
in the list box, and then type the directory path (without quotation
marks) of the resource
template file that you saved in step 6.
Alternatively, you can click in the corner of the list box to
display an ellipsis button (...) that you can click to display a dialog box. You can use
this dialog box to point to the directory that contains the resource template
file that you saved in step 6. - Click OK in the Additional Include
Directories dialog box.
Note Make sure that the path string in the Additional Include
Directories property is not enclosed in quotation marks. If the path
of the .rct file includes spaces, and you used the ellipsis button (...) to choose
the folder, by default, it is enclosed in quotation marks. You must remove the
quotation marks in such cases. Also if you type the path, you must
make sure that you type the correct path with the exact number of
spaces. - Click Apply, and then click
OK to close the ProjectName
Property Pages dialog box.
- In Solution Explorer, click the Resource
View tab.
- In Resource View, expand the
ProjectName node.
- Expand the folder that corresponds to the resource
file.
- Right-click the Dialog folder, and then
click Add Resource.
- In the Add Resource dialog box, expand
Dialog under Resource Type. You
notice the dialog resource that you want to copy.
- Click the dialog resource that you want to copy, and then
click New to add this dialog resource to your
project.
- Press the CTRL+SHIFT+S key combination to save the
project.
- On the File menu, click Close
Solution to close the solution.
- Exit Visual Studio .NET or Visual Studio 2005.
Back to the
topREFERENCESFor more information about copying resources from one
project to another, visit the following Microsoft Developer Network (MSDN) Web
site: Back to the
top
Modification Type: | Major | Last Reviewed: | 12/30/2005 |
---|
Keywords: | kbImport kbHOWTOmaster kbResource kbhowto KB829437 kbAudDeveloper |
---|
|
|
©2004 Microsoft Corporation. All rights reserved.
|
|