How to copy dialog box resources in VC ++

Source: Internet
Author: User

Method 1:

Add the RC file of another project to your project. In this case, two RC files will appear in the resource view. Copy the resources from the RC file added after the resource view to the RC file of your project.

 

Method 2:In VC, how does one copy the dialog box resources of a project to another project?

This is a very professional and useful question. In fact, VC designers have long considered this issue for us.
In the vc6 environment, select the Class View and select the class corresponding to the dialog box to be cloned, such as caboutdlg. Right-click and choose add to gallery. In the new project, select the project menu and add component and activx. You will see a folder (with the same name as the previous project), enter the folder, and select *. OGX. Select Insert. You will find that the original dialog box is added to the new project! Supplement:

. NET is simpler. Add the original project to the new project and copy the dialog box directly! Method 3: How to copy dialog box resources in VC ++

Step 1: use NotePad to open the. RC file of the original project and find the information of the dialog box to be copied, as shown below:

Idd_ugms_dialogdialogex 0, 0,320,230
Style ws_child | ws_visible
Exstyle ws_ex_appwindow
Font 9, ""
Begin
Groupbox "student information", idc_static, 290,200
Groupbox "", idc_static, 205,120
Pushbutton "Top (& F)", idc_button_first, 30,30, 35,15
Pushbutton "Forward (& B)", idc_button_pre, 82,30, 35,15
Pushbutton "backward (& n)", idc_button_next, 134,30, 35,15
Pushbutton "last (& L)", idc_button_last, 186,30, 35,15
Pushbutton "query (& Q)", idc_button_query, 24, 70, 40, 15
Pushbutton "add (& A)", idc_button_add, 246,96
Pushbutton "Modify (& M)", idc_button_modify, 246,122
Pushbutton "Delete (& D)", idc_button_delete, 246,148
Pushbutton "OK (& O)", idc_button_ OK, 58,183
Pushbutton "cancel (& C)", idc_button_cancel, 150,183
Ltext "student ID:", idc_static
Ltext "name:", idc_static, 52,100
Ltext "Gender:", idc_static, 52,125
Ltext "admission time:", idc_static, 44,151
Edittext idc_edit_sid, 91,72, 95,15, es_autohscroll
Edittext idc_edit_sname, 91,96, 95,15, es_autohscroll
Edittext idc_edit_ssex, 91,120, es_autohscroll
Control "datetimepicker1", idc_datetimepicker_scomedate,
& Quot; sysdatetimepick32 & quot;, dts_rightalign | ws_tabstop, 91,144,
95,15
Groupbox "", idc_static, 35
End

In the above Code, the green background indicates the ID of the dialog box resource to be copied. This section of code is the information of this dialog box recorded in the. RC file. The code in the middle of the yellow background is

For the control information added in the corresponding dialog box, you only need to copy the corresponding code to the begin and end of the corresponding ID dialog box of the corresponding. RC file of the new project;

Step 2: Open the resource. h file under header files in the FileView view of the original project, and copy the corresponding ID information to resource. H of the new project;

For example:

// Copy the resource ID
# Define idc_button_first 1000
# Define idc_button_pre1001
# Define idc_button_next 1002
# Define idc_button_last 1003
# Define idc_button_query 1004
# Define idc_button_add 1005
# Define idc_button_modify 1006
# Define idc_button_delete 1007
# Define idc_button_ OK 1008
# Define idc_button_cancel 1009
# Define idc_edit_sid 1010
# Define idc_edit_sname 1011
# Define idc_edit_ssex 1012
# Define idc_datetimepicker_scomedate 1013

Step 3: Do not omit it. If there is a duplicate ID, you can change it!

 

Method 4:

The module porting problem is encountered today. The self-made dialog box class (inherited from cdialog) should be transplanted to the target project. I searched several posts on the Internet and found that they all said it was quite cool. after asking our Technical Director, we finally solved the problem. problem: copy a dialog box resource and class in an mfc sdi project to another mfc sdi project. 1. open the old project in vc6, and select the resource file in the dialog folder on the "resource" tab of the work zone (that is, the one in the editing window that appears after double-clicking ), press Ctrl + C (edit-> copy ). 2. close the current project. Do not close vc6. Open the target project (file-> openworkspace) and select the dialog folder in the resource tab of the workspace, then press Ctrl + V (edit-> paste ). now, the dialog box is copied. 3. copy the CPP hfile of the dialog box class to the target project (add a file to the current project. open the copied CPP and H files and delete useless header files. (Related to the old project), and in. # include "resource. H "Step 4 is critical. This file is not included in the root of the old project, but you must manually add the header file after transplantation. it took 10 minutes because of this problem... then you can use this class in the new project. This is mainly the first time the resource is copied in the dialog box of this class. I am afraid to enjoy it exclusively. I will take it out to study with new users. therefore, when resources in the created dialog box need to be added to the new project: (1) Right-click the solution where the new project is located and add "existing project" to add the old project. (2) switch to "resource view" and Right-click "copy" on the resources in the old project dialog box. (3) Right-click "Paste" on the resources in the new project dialog box. (4) now you can add a class for the new dialog box. By the way, copy the response function of the old project. (5) switch back to Solution Explorer and right-click the old project and choose remove ".

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.