This note describes the ID naming and numbering conventions used by MFC for resources, commands, strings, controls, and child windows. The Problem The MFC ID naming and numbering conventions are intended to meet the following requirements: · Provide a consistent ID-naming standard used across the MFC library and MFC applications that are supported by the Visual C++ resource editor. This allows the programmer to more readily interpret IDs as to their type and origin. · Emphasize the strong 1-to-1 relationship between certain types of IDs. This helps to clarify MFC's application framework architecture. · Conform to already widely used standards for naming IDs in Windows. · Partition the ID-numbering space, so as to avoid unintentional duplication of ID numbers among those assigned by the programmer, by MFC and Windows, and by Visual C++-edited resources. Overview of ID Prefix Naming Convention There are several categories or types of IDs in an application. The MFC ID-naming convention defines different prefixes for different resource types. MFC uses the prefix "IDR_" to refer to a resource ID that applies to multiple resource types. For example, for a given frame window, the same "IDR_" value is used to refer to a menu, accelerator, string and icon resource all at once. IDR_ Multiple resource types (Used for Menus, Accelerators primarily). IDD_ For dialog template resources (for example, IDD_DIALOG1). IDC_ For Cursor resources. IDI_ For Icon resources. IDB_ For Bitmap resources. IDS_ For String resources. Note that the IDS_ value for a string resource is the ID passed to LoadString. The actual implementation of string table resources groups together 16 strings into one segment. Within a DIALOG resource, we follow the convention of: IDOK,IDCANCEL For standard push button IDs. IDC_ For other dialog controls. The "IDC_" prefix is also used for cursors. This naming conflict is not usually a problem since a typical application will have few cursors and a large number of dialog controls. Within a Menu resource, we follow the convention of: IDM_ For menu items not using the MFC command architecture. ID_ For menu item commands using the MFC command architecture. Commands that follow the MFC command architecture must have an ON_COMMAND command handler and may have an ON_UPDATE_COMMAND_UI handler. If these command handlers follow the MFC command architecture, they will function correctly whether they are bound to a menu item, a toolbar button or a dialog bar button. The same ID_ is also used for a menu prompt string displayed on the program's message bar. Most of the menu items in your application should follow the MFC command convention. All of the standard command IDs (for example, ID_FILE_NEW) follow this convention. MFC also uses "IDP_" as a specialized form of strings (that is, instead of "IDS_"). Strings with the "IDP_" prefix are "prompts," that is, strings used in message boxes. "IDP_" strings may contain "%1" and "%2" as place holders of strings determined by the program. "IDP_" strings usually have help topics, while "IDS_" strings do not. "IDP_" strings are always localized, while "IDS_" strings may or may not be localized. The MFC library also uses the "IDW_" prefix as a specialized form of control IDs (that is, instead of "IDC_"). These IDs are assigned to child windows such as views and splitters by the framework classes. MFC implementation IDs are prefixed with "AFX_". Overview of MFC ID-Numbering Convention The following lists the valid ranges for the IDs of the specific types. Some of the limits are technical implementation limits while others are just conventions to prevent your IDs from colliding with Windows predefined IDs or MFC default implementations. We strongly recommend you do not defined IDs outside the recommended ranges. Even though the lower limit of many of these ranges is 1 (0 is not used), common convention starts practical use of IDs at 100 or 101. Prefix Resource Type Valid Range IDR_ multiple 1 -> 0x6FFF IDD_ dialog templates 1 -> 0x6FFF IDC_,IDI_,IDB_ cursors, icons, bitmaps 1 -> 0x6FFF IDS_, IDP_ general strings 1 -> 0x7FFF ID_ commands 0x8000 -> 0xDFFF IDC_ controls 8 -> 0xDFFF Reasons for these range limits: · By convention, the ID value of 0 is not used. · Windows implementation limitations restrict true resource IDs to be less than or equal to 0x7FFF. · MFC's internal framework implementations reserve several ranges: 0xE000->0xEFFF and 0x7000->0x7FFF. · Several Windows system commands use the range of 0xF000 -> 0xFFFF. · Control IDs of 1->7 are reserved by IDOK, IDCANCEL, and so on. · The range of 0x8000->0xFFFF for strings is reserved for menu prompts for commands. *************************************************************************************************** *************************************************************************************************** Overview of Weekly MFC EXTension ID-Numbering Convention -------------------------------------------------------- The following lists the valid ranges for the IDs of the specific types for the Weekly MFC EXTension. We strongly recommend you do not defined IDs outside the recommended ranges. It's also recommeded to reserve a smaller range specifically for each class or app you need resources for. Prefix Resource Type Valid Range IDR_ multiple 23000 -> 25999 IDD_ dialog templates 23000 -> 25999 IDC_,IDI_,IDB_ cursors, icons, bitmaps 23000 -> 25999 IDC_ controls 23000 -> 25999 IDS_, IDP_ general strings 23000 -> 25999 ID_ commands(routable) 53000 -> 54999 Ranges already in use --------------------- Class/App Range *************************************************************************************************** *************************************************************************************************** MESSAGE RESOURCES FACILITY ID ----------------------------- AutomaticUpdate = 0x101 : FACILITY_AUTOMATIC_UPDATE MailBackService = 0x102 : FACILITY_MBS DistributionList = 0x110 : FACILITY_DIST_LIST #define OX_FACILITY_REGISTRY_WATCHER 0x221 *************************************************************************************************** *************************************************************************************************** APPLICATION AND USER DEFINED MESSAGES ------------------------------------- #define WM_USER 0x0400 [WinUser.h] #define WM_APP 0x8000 [WinUser.h] #ifndef WM_OX_APP // You can redefine WM_OX_APP by defining it before including this file #define WM_OX_APP WM_APP + 100 #endif #define WM_POST_INIT (WM_OX_APP + 110) [OXEditList.h] #define WM_POST_INIT (WM_OX_APP + 110) [OXNetBrowseTree.h] #define WM_POST_REDRAW (WM_OX_APP + 112) [OXColorButton.h] #define WM_CHECK_TRACK_LOOK (WM_OX_APP + 113) [OXBitmapButton.h] #define WM_EXP_DATA_EDIT (WM_OX_APP + 120) [OXExpForward.h] #define WM_EXP_TREE_EDIT (WM_OX_APP + 121) [OXExpForward.h] #define WM_EXP_TREE_OPEN (WM_OX_APP + 122) [OXExpForward.h] #define WM_EXP_TREE_CLOSE (WM_OX_APP + 123) [OXExpForward.h] #define WM_EXP_HANDLE_DRAG (WM_OX_APP + 124) [OXExpForward.h] // OXExpForward.h has the range +120 till +129 reserved #define WM_NOTIFY_TASKBAR_ICON (WM_OX_APP + 130) [OXTaskbarIcon.h] #define WM_OX_LISTHSCROLL (WM_OX_APP + 131) (OXMultiComboBox.h) #define WM_PROCESS_CELLEDIT (WM_OX_APP + 135) [OXCllEdt.h] #define WM_OX_FILE_NOTIFY (WM_OX_APP + 137) [OXFileWatcher.h] #define WM_OX_INTERNAL_SOUNDCALLBACK (WM_OX_APP + 140) [OXSound.h] #define WM_OX_SOUNDPLAYBACKCOMPLETE (WM_OX_APP + 141) [OXSound.h] #define WM_OX_SOUNDPLAYLOOPING (WM_OX_APP + 142) [OXSound.h] #define WM_OX_FILE_MATCH_FOUND (WM_OX_APP + 144) [OXFileChanger.h] #define WM_OX_FILE_PRE_REPLACE (WM_OX_APP + 145) [OXFileChanger.h] #define WM_OX_FILE_POST_REPLACE (WM_OX_APP + 146) [OXFileChanger.h] #define WM_OX_INSERTDATA (WM_OX_APP + 150) [OXDrag*Router.h] #define WMOX_FINAL_RELEASE (WM_USER + 1) [OXFinalReleaseWnd.h] #define WMOX_BROTHER_ACTIVATE (WM_USER + 1) [BrotherWatchWnd.h] #define WMOX_BROTHER_CLOSE (WM_USER + 2) [BrotherWatchWnd.h] #define WM_DOMDICLTREALIZE (WM_USER + 104) [XMDIClt.h] #define WM_DOREALIZE (WM_USER + 105) [XMmainFrm.h] #define WM_STAT_DBLCLICK (WM_USER + 555) [XStatus.h] #define WM_STAT_DBLCLICK (WM_USER + 555) [XStatus4.h] #define WM_LMSUROLLUP (WM_USER + 0x0400) [OXRollup.h] *************************************************************************************************** ***************************************************************************************************