DetailPage-MSS-KB

Microsoft small business knowledge base

Article ID: 829437 - Last Review: April 19, 2007 - Revision: 2.2

On This Page

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.

Requirements

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

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.
  4. In the Name text box, type DialogApp, and then click OK. By default, the Form1 form is created.
  5. In Solution Explorer, click the Resource View tab.
  6. In Resource View, expand the DialogApp node.
  7. Right-click the app.rc folder, and then click Add Resource.
  8. In the Add Resource dialog box, expand Dialog under Resource Type.
  9. 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.
  10. Right-click the dialog template, and then click Properties.
  11. Change the ID property to IDD_MY_FORMVIEW.
  12. Add a Button control to the dialog template.
  13. Press the CTRL+SHIFT+S key combination to save all files.
  14. On the File menu, click Close Solution to close the solution.
  15. 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.
  4. In the Name text box, type DialogApp, and then click OK.
  5. In the MFC Application Wizard - DialogApp dialog box, click Application Type.
  6. Under Application type, click to select Dialog based, and then click Finish.
  7. In Solution Explorer, click the Resource View tab.
  8. In Resource View, expand the DialogApp node.
  9. Right-click the DialogApp.rc folder, and then click Add Resource.
  10. In the Add Resource dialog box, expand Dialog under Resource Type.
  11. 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.
  12. Right-click the dialog template, and then click Properties.
  13. Change the ID property to IDD_MY_FORMVIEW.
  14. Add a Button control to the dialog template.
  15. Press the CTRL+SHIFT+S key combination to save all files.
  16. On the File menu, click Close Solution to close the solution.
  17. Exit Visual Studio .NET or Visual Studio 2005.

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.

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 FileName As.

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

    NoteProjectName is a placeholder for the name of the project that you opened.
  12. In the ProjectName Property Pages dialog box that appears, expand the Configuration Properties folder, and then click the Resources folder.
  13. Click the ellipsis button (...) next to the value for the Additional Include Directories property. The Additional Include Directories dialog box appears.
  14. 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.
  15. 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.
  16. Click Apply, and then click OK to close the ProjectName Property Pages dialog box.
  17. In Solution Explorer, click the Resource View tab.
  18. In Resource View, expand the ProjectName node.
  19. Expand the folder that corresponds to the resource file.
  20. Right-click the Dialog folder, and then click Add Resource.
  21. In the Add Resource dialog box, expand Dialog under Resource Type. You notice the dialog resource that you want to copy.
  22. Click the dialog resource that you want to copy, and then click New to add this dialog resource to your project.
  23. Press the CTRL+SHIFT+S key combination to save the project.
  24. On the File menu, click Close Solution to close the solution.
  25. Exit Visual Studio .NET or Visual Studio 2005.

REFERENCES

For more information about copying resources from one project to another, visit the following Microsoft Developer Network (MSDN) Web site:
http://msdn2.microsoft.com/en-us/library/a5axa064(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/a5axa064(vs.71).aspx)

APPLIES TO
  • Microsoft Visual C++ 2005 Express Edition
  • Microsoft Visual C++ .NET 2003 Standard Edition
  • Microsoft Visual C++ .NET 2002 Standard Edition
Keywords: 
kbimport kbhowtomaster kbresource kbhowto KB829437
Share
Additional support options
Ask The Microsoft Small Business Support Community
Contact Microsoft Small Business Support
Find Microsoft Small Business Support Certified Partner
Find a Microsoft Store For In-Person Small Business Support