Header Sep
Symbian OS Tips, Tricks & Code
Score
Login to rate page
 
August 2004
How to implement "floating" controls for the P800/P900/P910 smartphones

[Back]

On several occasions we've been asked how an application that's running in the background can indicate a change of status or prompt a user for some sort of action. This can be done by "floating" a control or dialog over the top of the foreground application.

Simple text prompts can be issued or simple dialogs (up to two lines of text with two buttons) can be displayed through the notifier framework. This is accomplished by using RNotifier, and full details (along with some example code fragments) are provided in the SDK documentation. Look under "Developer Library » Symbian OS Guide » C++ API guide » Base » Inter Process Communication » Using Notification Services". But what if you want to do something more sophisticated? One solution is shown in the example application found in the CueControl .zip archive file.

There is a pre-built .sis-file in the .zip archive that can be installed on the Sony Ericsson P800, P900 and P910 smartphones. To make it for a handset, use the following commands:

$ bldmake bldfiles
$ abld build thumb urel
$ makesis cuecontrol.pkg

This builds "CueControl.sis" that can be installed on the handset. Start the CueControl application and activate another application. Pressing the camera button on the handset will display a red dot "floating" over the current application, as shown in the below screenshot.

The declaration of the "floating" control looks like this:

class CCueControl :
     public CCoeControl
{
public:
     void ConstructL(const TRect& aRect, RWindowGroup* aWindowGroup);
       CCueControl();
       ~CCueControl();
protected:
     // overrides : CCoeControl
     virtual void Draw(const TRect& aRect) const;
};

The AppUi class of the application contains the following member variables:

RWindowGroup iFWinGroup ;
CCueControl* iVCuecontrol ;

In the second-phase constructor of the application's AppUi class; create a new window group and set the ordinal position of the window group above that of active applications:

RWsSession& session = CCoeEnv::Static()->WsSession();
iFWinGroup = RWindowGroup(session);
TInt res = iFWinGroup.Construct((TUint32)&iFWinGroup, EFalse);
if ( res != KErrNone )
     {
     // Do something if second phase construction of the RWindowGroup
     // Fails!
     }
iFWinGroup.SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);

You can now create a control (derived from the CcoeControl class) that renders your message/graphics in the window group you've just created:

if (!iVCuecontrol)
     {
     iVCuecontrol = new (ELeave) CCueControl();
     iVCuecontrol->ConstructL( ClientRect(), &iFWinGroup);
     AddToStackL( iVCuecontrol );
}

iVCuecontrol should display over the top of any application window group with an ordinal position "priority" below ECoeWinPriorityAlwaysAtFront.

Download zip file with CueControl example>> 
 

 

Score
Login to rate page