Symbian3/SDK/Source/GUID-B57ECD51-85EF-50EA-B3EE-62A85CD9C382.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?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-B57ECD51-85EF-50EA-B3EE-62A85CD9C382" xml:lang="en"><title>How
to use a notifier to display a simple dialog, asynchronously</title><shortdesc>Provides code snippets to show you how to use a notifier to display
a simple dialog asynchronously.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>To display a simple dialog box:</p>
<ul>
<li id="GUID-9BB8982B-727E-57FB-951F-EEA8CA49D203"><p>construct an <codeph>RNotifier</codeph> object
and then call its <codeph>Connect()</codeph> member function to create a session
with the Notifier server.</p> </li>
<li id="GUID-F6523ED3-4816-538B-86BB-576A05E47197"><p>call the <codeph>Notify()</codeph> member
function of the <codeph>RNotifier</codeph>, passing descriptors containing
the two lines of text to be displayed and the characters for the buttons. <codeph>Notify()</codeph> makes
an asynchronous request to the notifier server.</p> </li>
</ul>
<p>When the user keys in one of the button characters, the requesting thread's <keyword>request
semaphore</keyword> is signalled to indicate that the notifier request is
complete. The <codeph>TRequestStatus</codeph> object supplied by the requesting
thread is set to <codeph>KErrNone</codeph>.</p>
<p>In addition, a <codeph>TInt</codeph>, passed by reference to <codeph>Notify()</codeph>,
is set to 0 or 1 depending on whether the first or the second button is selected.</p>
<p>The session is closed by calling the <codeph>Close()</codeph> member function
of the <codeph>RNotifier</codeph>.</p>
<p>The following code fragments demonstrate this:</p>
<codeblock id="GUID-8FDAA342-A5C9-5D27-B3DE-8F62124BADA4" xml:space="preserve">{
_LIT(KTxtLine1,"First line");
_LIT(KTxtLine2,"Second line");
_LIT(KButt1,"a");
_LIT(KButt2,"b");
...
TInt           whichbutton(-1);
TRequestStatus stat;
...
RNotifier      notifier;
...
notifier.Connect();
...
notifier.Notify(KTxtLine1,KTxtLine2,KButt1,KButt2,whichbutton,stat);
...
// other code
...
User::WaitForRequest(stat);
...
if (whichbutton==0)
    {
    // first button selected
    }
if (whichbutton==1)
    {
    // Second button selected
    }
...
notifier.Close();
...
}</codeblock>
<p>Note that the descriptor parameters passed to <codeph>Notify()</codeph> must
remain in existence until the notify request completes; this may be some time
after the call to <codeph>Notify()</codeph> itself.</p>
</conbody></concept>