Symbian3/SDK/Source/GUID-D52E98C3-F5EE-4CE1-A4F5-2EF41A066B8A.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 21 Jan 2010 18:18:20 +0000
changeset 0 89d6a7a84779
permissions -rw-r--r--
Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
	Nokia Corporation - initial contribution.
Contributors: 
-->  <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"><concept id="GUID-D52E98C3-F5EE-4CE1-A4F5-2EF41A066B8A" xml:lang="en"><title>Creating
resource header files</title><prolog><metadata><keywords></keywords></metadata></prolog><conbody>
<p>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:</p>
<ul>
<li><p>Custom command IDs used for mapping mobile device user input
based upon <parmname>Options</parmname> menu selections to command handling.
These custom command IDs are mapped to the text displayed for the command
in the <parmname>Options</parmname> menu in resource files, and then are passed
back to the application by the application framework.</p></li>
<li><p>Control IDs in dialogs to allow references to the dialog
controls from C++ code.</p>
<itemgroup>
<p>For more information on control IDs for dialogs, see Using Dialogs API.</p>
</itemgroup>
</li>
<li><p>Application view IDs. Note that these could also be enumerated
in the header files for the views.</p></li>
<li><p>IDs for other resource structures, such as for <parmname>TABS</parmname> in
the status pane.</p></li>
</ul>
<p>These enumerated values need to be defined in a resource file, which
by convention has the extension <parmname>hrh</parmname>, The syntax is as
follows:</p>
<codeblock xml:space="preserve" id="GUID-2CDD719A-48CA-47EF-A737-7CCB62DF6FC6">enum TCommandIds
    {
    ECmdAppTest1 = 1,
    ECmdView1Cmd1,
    ECmdView1Cmd2,
    ECmdView1Cmd3,
    ECmdView2Cmd1,
    ECmdView2Cmd2,
    ECmdView2Cmd3,
    ECmdView2Cmd4
    };</codeblock>
<p>where</p>
<ul>
<li><p><parmname>enum</parmname> is the keyword declaration the
set of integer values. Note that you would use this keyword for each set of
enumerated values you defined.</p></li>
<li><p><parmname>TCommandIds</parmname> is a label for the list
of enumerated values. This label is not used in the code or resource files.</p>
</li>
<li><p><parmname>ECmdAppTest1</parmname> is a symbol that can be
used in your code or resource files</p></li>
<li><p><parmname>=</parmname> is the operator used for setting the
value to the symbol</p></li>
<li><p><parmname>1</parmname> is the specific value assigned to
the enumerator symbol</p></li>
</ul>
<p>Each enumerator is followed by a <parmname>,</parmname>, except for
the last value. It is recommended to have a final <parmname>;</parmname> 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 <parmname>ECmdView1Cmd1</parmname> above is 2.</p>
<p>For more information about the use of the <parmname>enum</parmname> statement,
see <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/ToolsAndUtilities94/DevTools-ref/ResourceFileFormat/Tool_Ref_RSS-file-format-ENUM.html#DevTools%2dref%2erss%2denum" format="application/java-archive">ENUM statement</xref>.</p>
</conbody></concept>