During MFC development, if some resources are transplanted to this project from other projects, the corresponding resource IDS should be copied to the resource. H file of this project during resource transplantation. If you add a resource ID to the project or not, the ID in the resource. H file may be duplicated. In addition, with more and more interfaces, the ids of the various control dialogs are piled on top of each other, making it annoying to look at.

Today I put together a small tool, can open the Resource. H file for conversion, can solve this problem. Reorder and repeat the ID.

1. Instructions for use

(1) This program rearranges and sorts the IDS in MFC Resource file resource-h; Sort alphabetically and reject duplicate ids;

(2) For fear of causing unexpected problems, the program will not change the default resource serial number of the original MFC, for example:

#define IDR_MAINFRAME 128

Maintain the status quo

(3) The encoding of the resource. H file must be the default ANSI of Windows system; otherwise, garbled characters will appear; (4) If the RIBBON toolbar is used in the MFC project, manually delete the ribbon. Mfcribbon-ms file in the RES folder and rebuild it. Otherwise, the MFC project will report an error. Because the ids in the Ribbon file have been reordered, misaligned ids can cause message mappings to be messed up.

How to delete rebuild ribbon. Mfcribbon-ms?

Go to VS Resources ->*. Rc ->Ribbon->IDR_RIBBON. Double-click to open the Ribbon toolbar.

Delete ribbon. Mfcribbon-ms file from res. Open the ribbon toolbar in the resource view. Otherwise, the ribbon. Mfcribbon-ms file will not open the toolbar after deletion.

Go to the ribbon toolbar, modify any menu text or icon, and click Save. The ribbon. Mfcribbon-ms file will be automatically generated.

(5) In addition, please note that the text opens the res\*. Rc file, jumps to the Icon column, Microsoft official said:

// Icon with lowest ID value placed first to ensure application icon

// remains consistent on all systems.

That is, the icon used by the object file, exe, takes precedence over the icon file with the smallest ID.

So you need to confirm that the value of the IDR_MAINFRAME is smaller than the IDS of other ICO files.

(6) To be prudent, it is recommended to back up the Resource. H and ribbon. Mfcribbon-ms files before conversion

 

2, complete source code and executable file please download:

Download.csdn.net/download/li…

 

 

— Extended reading, I learned from the tutorials I searched online

How does MFC delete unused resource symbols?

1: Open the Resource view (CTRL + Shift + E, or open it from view options, or double click on the.rc file in the resource folder) 2: right click on the.rc folder in the resource view, open the resource symbol item ID= Resource symbol item 3: In the pop-up dialog box, you can see which resource symbols are in use and which are not 4: You can delete unused resource symbols — firecat note: I feel unreliable, easy to delete by error.



Create a standard MFC program and notice that there is a macro definition in Resource. H by default

// Next default values for new objects  

//

#ifdef APSTUDIO_INVOKED

#ifndef APSTUDIO_READONLY_SYMBOLS

#define _APS_3D_CONTROLS 1

#define _APS_NEXT_RESOURCE_VALUE 130

#define _APS_NEXT_COMMAND_VALUE 32773

#define _APS_NEXT_CONTROL_VALUE 1000

#define _APS_NEXT_SYMED_VALUE 101

#endif

#endif

Using a simple single-document program I had built, I found some clues, #define _APS_NEXT_CONTROL_VALUE 1000, so I created a dialog and pulled out a control, recompiled it, and then went back to Resource. Its ID is exactly 1000, and I’m sure you already know how to use the other ones. Firecat Note: These macros specify where the ID starts each time a new control is added. You can modify it yourself.