Wednesday, February 4, 2009

[VC++] Copying resource(.rc) content from one project to other

If you want to copy the content of one .rc file to another .rc file how you can do (for eg: copying one dialog from one project to another) ?
Traditional approach is to compare two .rc files (in text mode), then copy paste the needed lines. Also add corresponding resource id to resource.h with proper values. Care should be taken not to have same resource id or values. This is an erroneous undertaking right ? So do not go for this what is next ?

  • Open your project in VC++ .

  • Take File->Open & browse for the .rc file from which you want to copy.

  • Open the .rc file specifying Open as Auto.

  • Now you can see choosen .rc file open as in resource view (see below snapshot).

  • Select the dialog (or dialog controls such as buttons ) and press Ctrl+C to copy.

  • Now select the Workspace->Resource view and paste by pressing Ctrl+V. For eg: If you copied a dialog then select the dialog of Resource view and press Ctrl+V, if you copied some button controls click and open the dialog you want to paste it and press Ctrl+V.

  • You can also drag and drop resource, in such a case take care not to save the source .rc file.


Then it is done ! All the .rc file updation, resource.h updation done automatically !!!

No comments: