简体   繁体   中英

Gap in resource IDs for a new ATL project in Visual Studio 2010

When I create a brand new ATL project in Visual Studio 2010, resource IDs 102 and 105 are left out. Is this intentional or a bug? Do these IDs serve any purpose later in the project? Can I reorder the numbering to use these? Here is the resource file for a new project named TestID:

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by TestID.rc
//

#define IDS_PROJNAME                    100
#define IDR_TESTID  101
#define IDR_PREVIEW_HANDLER             103
#define IDR_THUMBNAIL_HANDLER           104

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        201
#define _APS_NEXT_COMMAND_VALUE         32768
#define _APS_NEXT_CONTROL_VALUE         201
#define _APS_NEXT_SYMED_VALUE           106
#endif
#endif

ID 102 is left out then the next ID (_APS_NEXT_SYMED_VALUE) is set to 106 so 105 is left out too.

The reason is simple and it depends on the ATL Project you want to create. I just looked into the folder \\VC\\VCWizards\\AppWiz\\ATL\\ATLProject\\templates\\1033\\ for the resource.h file.

[!if SERVICE_APP]
#define IDS_SERVICENAME                 100
[!else]
#define IDS_PROJNAME                    100
[!endif]
#define IDR_[!output UPPER_CASE_SAFE_PROJECT_IDENTIFIER_NAME]   101
[!if PREVIEW_HANDLER]
#define IDR_PREVIEW_HANDLER             103
[!endif]
[!if THUMBNAIL_HANDLER]
#define IDR_THUMBNAIL_HANDLER           104
[!endif]
[!if SEARCH_HANDLER]
#define IDR_FILTER_HANDLER              105
[!endif]

As you can see there are conditionals that are executed by the app-wizard code that might include also IDs with 104 and 105. So to fit all cases the next free id is set to 106.

But you are free to renumber all existing resources.

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