Chapter 12: Dialog-Based Windows Visual C++ and MFC Fundamentals
IDC_EDIT1. If you add another control of the same kind, it would receive an identifier
with an incremental number.
To have a better idea of each control, you should change its ID to make it more intuitive.
To do this, if you are visually adding the control, first display the Properties window:
The identifier can be a word or a hexadecimal number. Here are the rules you must
follow when assigning identifiers:
If you decide to use a word If you decide to use a hexadecimal number
?? The identifier must start with an
underscore or a letter
?? The identifier must be in one word
?? After the first character, the identifier can
have letters, underscores, and digits in
any combination
?? The identifier must not have non-
alphanumeric characters
?? The identifier cannot have space(s)
?? The identifier must start with a digit or one of the
following letters: a, b, c, d, e, f, A, B, C, D, E, or
F
?? The identifier can have only digits and the above
letters except this: if the identifier starts with 0,
the second character can be x or X followed by
the above letters and digits so that, when
converted to decimal, it must have a value
between -32768 and 65535
Here are suggestions you should follow:
?? The identifier should be in all uppercase
?? The identifier should have a maximum of 30 characters
?? If the object is a form or dialog box, its identifier should start with IDD_ followed by
a valid name. Examples: IDD_EMPLOYEES or IDD_EMPL_RECORS
?? If you are creating a control, the identifier should start with IDC_ followed by a
name. Examples are: IDC_ADDRESS or IDC_FIRST_NAME
?? If you are creating a static control but plan to use it in your code, (you must) change
its identifier to something more meaningful. If the static control will hold text and
you plan to change that text, you can identify it with IDC_LABEL. For a static
control used to display a picture of employees, you can identify it as
IDC_EMPL_PICTURE
The identifiers of the controls used in your application must be listed in a header file.
This file is usually called Resource.h