Microsoft KB Archive/829437

= How to import a dialog resource from one project to another project by using Visual C++ .NET or Visual C++ 2005 =

Article ID: 829437

Article Last Modified on 4/19/2007

-

APPLIES TO


 * Microsoft Visual C++ 2005 Express Edition
 * Microsoft Visual C++ .NET 2003 Standard Edition
 * Microsoft Visual C++ .NET 2002 Standard Edition

-





IN THIS TASK

 * SUMMARY
 * Requirements
 * Create dialog-based applications in Visual C++ .NET
 * Copy a dialog resource
 * Use a resource template
 * REFERENCES



SUMMARY
This 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 top

Requirements
This article assumes that you are familiar with the following topics:
 * Programming with Visual C++ .NET or Visual C++ 2005
 * Resource files

Back to the top

Create dialog-based applications in Visual C++ .NET or in Visual C++ 2005
In 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:
 * 1) Start Microsoft Visual Studio .NET 2003 or Microsoft Visual Studio 2005.
 * 2) On the File menu, point to New, and then click Project.
 * 3) 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.
 * 1) In the Name text box, type DialogApp, and then click OK. By default, the Form1 form is created.
 * 2) In Solution Explorer, click the Resource View tab.
 * 3) In Resource View, expand the DialogApp node.
 * 4) Right-click the app.rc folder, and then click Add Resource.
 * 5) In the Add Resource dialog box, expand Dialog under Resource Type.
 * 6) 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.
 * 1) Right-click the dialog template, and then click Properties.
 * 2) Change the ID property to IDD_MY_FORMVIEW.
 * 3) Add a Button control to the dialog template.
 * 4) Press the CTRL+SHIFT+S key combination to save all files.
 * 5) On the File menu, click Close Solution to close the solution.
 * 6) 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:
 * 1) Start Microsoft Visual Studio .NET or Visual Studio 2005.
 * 2) On the File menu, point to New, and then click Project.
 * 3) 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.
 * 1) In the Name text box, type DialogApp, and then click OK.
 * 2) In the MFC Application Wizard - DialogApp dialog box, click Application Type.
 * 3) Under Application type, click to select Dialog based, and then click Finish.
 * 4) In Solution Explorer, click the Resource View tab.
 * 5) In Resource View, expand the DialogApp node.
 * 6) Right-click the DialogApp.rc folder, and then click Add Resource.
 * 7) In the Add Resource dialog box, expand Dialog under Resource Type.
 * 8) 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.
 * 1) Right-click the dialog template, and then click Properties.
 * 2) Change the ID property to IDD_MY_FORMVIEW.
 * 3) Add a Button control to the dialog template.
 * 4) Press the CTRL+SHIFT+S key combination to save all files.
 * 5) On the File menu, click Close Solution to close the solution.
 * 6) Exit Visual Studio .NET or Visual Studio 2005.

Back to the top

Copy a dialog resource
To 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.
 * 1) Start Visual Studio .NET or Visual Studio 2005.
 * 2) On the File menu, point to Open, and then click File.
 * 3) Locate the source resource file.
 * 4) Click the resource file, and then click Open to open the file.
 * 5) Perform steps 2 through 4 for the destination resource file.
 * 6) To switch to the source resource file, click the tab that contains the file name of this file.
 * 7) Expand the folder that has the same name as the file name of the source resource file.
 * 8) Expand the Dialog folder.
 * 9) Right-click the dialog resource that you want to copy, and then click Copy.
 * 10) To switch to the destination resource file, click the tab that contains the file name of this file.
 * 11) 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.
 * 12) Press the CTRL+SHIFT+S key combination to save all files.
 * 13) On the File menu, click Close Solution to close the solution.

Back to the top

Use a resource template
To import a dialog resource from a resource template file of a Visual C++ .NET project to another project, follow these steps:
 * 1) Start Visual Studio .NET or Visual Studio 2005.
 * 2) On the File menu, point to Open, and then click File.
 * 3) Locate the source resource file.
 * 4) Click the resource file, and then click Open to open the file.
 * 5) On the File menu, click Save   As.

Note  is a placeholder for the file name of the resource file.
 * 1) To save the resource file as a resource template file, select Resource Template (*.rct) in the Save as type list, and then click Save.
 * 2) On the File menu, click Close to close the resource file.
 * 3) On the File menu, click Open Solution.
 * 4) In the Open Solution dialog box, locate the target project to where you must copy the dialog resource file.
 * 5) Click the solution file, and then click Open.
 * 6) In Solution Explorer, right-click  , and then click Properties.

Note is a placeholder for the name of the project that you opened.
 * 1) In the   Property Pages dialog box that appears, expand the Configuration Properties folder, and then click the Resources folder.
 * 2) Click the ellipsis button (...) next to the value for the Additional Include Directories property. The Additional Include Directories dialog box appears.
 * 3) 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.
 * 1) 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.
 * 1) Click Apply, and then click OK to close the   Property Pages dialog box.
 * 2) In Solution Explorer, click the Resource View tab.
 * 3) In Resource View, expand the   node.
 * 4) Expand the folder that corresponds to the resource file.
 * 5) Right-click the Dialog folder, and then click Add Resource.
 * 6) In the Add Resource dialog box, expand Dialog under Resource Type. You notice the dialog resource that you want to copy.
 * 7) Click the dialog resource that you want to copy, and then click New to add this dialog resource to your project.
 * 8) Press the CTRL+SHIFT+S key combination to save the project.
 * 9) On the File menu, click Close Solution to close the solution.
 * 10) Exit Visual Studio .NET or Visual Studio 2005.

Back to the top

