Symbian3/SDK/Source/GUID-D52E98C3-F5EE-4CE1-A4F5-2EF41A066B8A.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 12:39:03 +0100
changeset 8 ae94777fff8f
parent 7 51a74ef9ed63
child 13 48780e181b38
permissions -rw-r--r--
Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?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/></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 <xref format="html" href="specs/guides/Dialogs_API_Specification/Dialogs_API_Specification.html#Dialogs_API_Specification.topic3" scope="external">Using
Dialogs API</xref>.</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 id="GUID-2CDD719A-48CA-47EF-A737-7CCB62DF6FC6" xml:space="preserve">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. </p>
<note>
<p>Use this keyword for each set of enumerated values you defined.</p>
</note>
</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 comma (<codeph>,</codeph>) except for
the last value. It is recommended to have a final semi colon (<codeph>;</codeph>)
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>