Typically when you create an application, there are cases where you need to create an enumerated set of command IDs (which are symbols with integer values). These defined symbols can then be used in both your code and resource files. Common examples of these cases, include:
Custom command IDs used for mapping mobile device user input based upon Options menu
selections to command handling. These custom command IDs are mapped to the
text displayed for the command in the Options menu in
resource files, and then are passed back to the application by the application
framework.
Control IDs in dialogs to allow references to the dialog controls from C++ code.
For more information on control IDs for dialogs, see Using Dialogs API.
Application view IDs. Note that these could also be enumerated in the header files for the views.
IDs for other resource structures, such as for TABS in
the status pane.
These enumerated values need to be defined in a resource file, which
by convention has the extension hrh, The syntax is as
follows:
enum TCommandIds { ECmdAppTest1 = 1, ECmdView1Cmd1, ECmdView1Cmd2, ECmdView1Cmd3, ECmdView2Cmd1, ECmdView2Cmd2, ECmdView2Cmd3, ECmdView2Cmd4 };
where
enum is the keyword declaration the set of integer
values. Note that you would use this keyword for each set of enumerated values
you defined.
TCommandIds is a label for the list of enumerated
values. This label is not used in the code or resource files.
ECmdAppTest1 is a symbol that can be used in your
code or resource files
= is the operator used for setting the value to
the symbol
1 is the specific value assigned to the enumerator
symbol
Each enumerator is followed by a ,, except for
the last value. It is recommended to have a final ; after
the enumerated list. If a specific value is not assigned to a symbol in the
enumerated list, then the value is that of the previous enumerator plus one.
Thus, the value for ECmdView1Cmd1 above is 2.
For more information about the use of the enum statement,
see ENUM statement in the Symbian OS Library.