<enum-statement> enum-statement ::= enum [<enum-label> ] { <enum-list> };
Use an enum (or an ENUM) statement to define a set of integer values. The values are associated with symbols defined in the enum-list; the syntax and the semantics are compatible with those of C++ enumerations. Note that the final semi-colon in an enum may be omitted; however, to retain compatibility with the C++ compiler, it is advisable to retain it.
Each member of the enum-list is followed by a comma except for the last one. The syntax of a member is defined as:
<enum-member> enum-member ::= <member-name> [ = <initialiser> ]
The defined enumerator symbols can be used in both C++ code and resource scripts and are commonly defined in files which have the conventional file extension hrh. The .hrh files are included in both C++ files and resource source files.
In general, each enumerator can be assigned a specific value. If no value is explicitly assigned, the value generated by the resource compiler is the value of the previous enumerator plus one. If the first enumerator is not assigned an explicit value, it defaults to 0.
The assigned value can be coded in either hexadecimal or plain decimal notation.
The enum definition:
enum { EExampleCmdIdFirst=0x100, EExampleCmdIdSecond, EExampleCmdIdThird, EExampleCmdIdFourth };
defines the enumerators EExampleCmdIdFirst, EExampleCmdIdSecond etc. and assigns values to them. EExampleCmdIdFirst is assigned the value 0x100 (decimal 256), EExampleCmdIdSecond is assigned the value 0x101 (decimal 257) etc.
enum { testvalue1=10, testvalue2, testvalue3=20, testvalue4 }; STRUCT TEST1 { BYTE b1; BYTE b2; BYTE b3; BYTE b4; } RESOURCE TEST1 test { b1=testvalue1; b2=testvalue2; b3=testvalue3; b4=testvalue4; }
In this example the resource generated is: 0x0A 0x0B 0x14 0x15