简体   繁体   中英

How to move dialog boxes of MFC project

I have made some changes in one version of MFC base code but now I want to copy a part of that changes including some dialog boxes to another project. Dialog boxes can be copied as it is to the new MFC project. but I could not find any file related to dialog boxes on cpp and header files are there . Please let me know is there a way to copy dialog boxes from one MFC project to another

Thanks

What you're probably looking for are the automatically generated and handled resource files like resource.h, resource.rc and friends. You can read more about them here: How to: Copy Resources and more in general here Resource Files (Visual Studio) .

While it's possible to open these files in Visual Studios' Resource View, they can be opened and viewed as Text as well; even in Visual Studio as long as the resource view is not currently open, but VS will tell you if that's the case.

Now MFC dialogs reference their used dialog template resource through an enum named IDD which is defined in the dialog's header file, fe

class CTest : public CDialog { /*...*/  enum { IDD = IDD_TEST_DIALOG }; }

so almost all you maybe have to do is to search for the specified resource id, look it up in the/one .rc-file and copy the needed parts (header + everything from BEGIN to END) over to your new project. As a second step then, you need to define unique values for all the resource id's which are used in that dialog (but not for common ones like IDOK though). This is usually done in resource.h:

#define IDD_TEST_DIALOG               142

so you have to copy all definitions which are used in your specific dialog to the target resource.h as well and make sure that there are no duplicate numbers. Please keep also in mind that there might exist multiple files which contain resources and some might be part of other projects resource only dll's fe .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM