Standard Command and Window IDs


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on

The latest version of this topic can be found at Standard Command and Window IDs.

The Microsoft Foundation Class Library defines a number of standard command and window IDs in Afxres.h. These IDs are most commonly used within the resource editors and the Properties window to map messages to your handler functions. All standard commands have an ID_ prefix. For example, when you use the menu editor, you normally bind the File Open menu item to the standard ID_FILE_OPEN command ID.

For most standard commands, application code does not need to refer to the command ID, because the framework itself handles the commands through message maps in its primary framework classes ( CWinThread, CWinApp, CView, CDocument, and so on).

In addition to standard command IDs, a number of other standard IDs are defined which have a prefix of AFX_ID. These IDs include standard window IDs (prefix AFX_IDW_), string IDs (prefix AFX_IDS_), and several other types.

IDs that begin with the AFX_ID prefix are rarely used by programmers, but you might need to refer to these IDs when overriding framework functions that also refer to the AFX_IDs.

IDs are not individually documented in this reference. You can find more information on them in Technical Notes 20, 21, and 22.

System_CAPS_ICON_note.jpg Note

The header file Afxres.h is indirectly included in Afxwin.h. You must explicitly include the following statement in your application's resource script (.rc) file:

#include "afxres.h"

Macros and Globals