Symbian3/SDK/Source/GUID-B7FF0B9C-3A17-5AAA-A986-7BA4F44DBD41.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 xml:lang="en" id="GUID-B7FF0B9C-3A17-5AAA-A986-7BA4F44DBD41"><title>Declaring a Window Server Event-Handling Class</title><shortdesc>The following example demonstrates how to declare an active object Window Server event handling class. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody><p> </p> <p> <b>Variant</b>: <xref href="GUID-D93978BE-11A3-5CE3-B110-1DEAA5AD566C.dita">ScreenPlay</xref> and <xref href="GUID-F64E6551-670E-5E12-8103-DE504D3EC94F.dita">non-ScreenPlay</xref>. <b>Target audience</b>: Application developers. </p> <p>The steps are: </p> <ul><li id="GUID-D311D61A-A40F-5202-B087-59A315D61015"><p>Provide a <xref href="GUID-067293BF-B28C-3CEC-92F4-1351A795EA7F.dita#GUID-067293BF-B28C-3CEC-92F4-1351A795EA7F/GUID-5D018F25-5173-36C1-A0B9-5C3A33211C5D"><apiname>CActive::RunL()</apiname></xref> function to handle the completion of an asynchronous request—that is, the event being received. </p> </li> <li id="GUID-62FE072C-7BAC-539E-BDF8-061E319DAB66"><p>Provide a <xref href="GUID-067293BF-B28C-3CEC-92F4-1351A795EA7F.dita#GUID-067293BF-B28C-3CEC-92F4-1351A795EA7F/GUID-4396079C-A0C9-3F40-82FD-1F47ABFFD511"><apiname>CActive::DoCancel()</apiname></xref> function to implement a cancellation request. </p> </li> <li id="GUID-0A86A321-0DDC-52EF-85C1-8099B1242C50"><p>Provide a function, here called <codeph>IssueRequest()</codeph>, to issue a request to the Window Server for events. </p> </li> <li id="GUID-F2970459-02CF-559F-B096-3620065F0089"><p>Create a <xref href="GUID-5D0B1595-1AC7-3C44-AC6B-0EFB5EABCF31.dita"><apiname>TWsEvent</apiname></xref> object to store the events. </p> </li> </ul> <codeblock id="GUID-2157B256-BC10-58D5-80F2-BA4FCF01BC9F" xml:space="preserve">/* An active object that wraps a Window Server session.
   An event being received causes RunL() to be called,
   where the event is processed. */

class CExampleWsClient : public CActive
    {
public:
 ...

    // Active object protocol
    void RunL ();
    void DoCancel();

    // Issue request to Window Server for events
    IssueRequest();

private:

    // Access to Window Server session 
    RWsSession&amp; iWs;

    // Access to screen device 
    CWsScreenDevice&amp; iScreen;

    // Window server general event
    TWsEvent iWsEvent;
    };</codeblock> <section><title>Issuing a request to the Window Server</title> <p>Once the active object has been constructed, a request can be issued. In the following code fragment, the active object provides the function <codeph>IssueRequest()</codeph> to invoke the encapsulated event request function. Pass the a <codeph>TRequestStatus</codeph> object, <codeph>iStatus</codeph>, to the <codeph>EventReady()</codeph> function to request Window Server events from the <codeph>iWs</codeph> Window Server session. </p> <p>Use the <xref href="GUID-067293BF-B28C-3CEC-92F4-1351A795EA7F.dita#GUID-067293BF-B28C-3CEC-92F4-1351A795EA7F/GUID-89083923-C044-3C7A-9FF8-6E5338533271"><apiname>CActive::SetActive()</apiname></xref> function, to indicate that the active object is currently active. </p> <codeblock id="GUID-0C12A024-2FCF-51BF-B477-1EFFD1CFAF03" xml:space="preserve">/* Request Window Server events */
void CExampleWsClient::IssueRequest()
    {
    iWs.EventReady(&amp;iStatus;); // request an event
    SetActive(); // so we're now active
    }</codeblock> </section> </conbody><related-links><link href="GUID-B58D3727-6E05-51C8-8EC2-52768A136BD5.dita"><linktext>Window Server Client-Side Events
                Overview</linktext> </link> <link href="GUID-7AC3477E-09C1-519A-9079-DA969B9FC4D7.dita"><linktext>General Events</linktext> </link> </related-links></concept>