Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

How to keep a window always as top window with Symbian device

From Wiki
Jump to: navigation, search
Article Metadata
Code Example
Source file:
Created: mahbub_s60 (13 Apr 2011)
Last edited: hamishwillee (26 Jul 2012)

This article explains how to force a window to remain in the foreground (always on top) using Symbian C++. It also explains the relationship between the window server and CoeControl class. The article has been tested on Symbian^1 and Symbian^3 devices.

Event from Keyboard to our control

CoeControl class keep a member variable of control environment (CCoenv) which in turn keep a instance to window server session. When something interested event happens then that is passed to our application as shown in the following image. Then our application react on the event as needed.


How to keep my window always on top

If we want to catch window server event we need to re implement the virtual function of CCoeAppUi in our AppUi class. This function is called whenever the window server sends key or pointer events or some other special events to the application.

virtual IMPORT_C void HandleWsEventL(const TWsEvent &aEvent, CCoeControl *aDestination);

First parameter is window server event and second parameter is the target control. We need to check the event and control if we are interested in. Following code example shows how we handle it to keep our control on the top.

void CKwikAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDest)
// let app framework handle the events first
CAknAppUi::HandleWsEventL(aEvent, aDest);
// is it for our special widget?
if (aDest == iAppView->Widget())
// is it visibility change event?
if (aEvent.Type() == EEventWindowVisibilityChanged)
const TWsVisibilityChangedEvent* vce = aEvent.VisibilityChanged();
// is our special widget now obscured by some other app?
if (vce->iFlags & TWsVisibilityChangedEvent::ENotVisible)
if (aEvent.Type() == EEventScreenDeviceChanged)
TInt curMode = iEikonEnv->ScreenDevice()->CurrentScreenMode();
if (curMode == 0) // portrait mode.
else // landscape mode.

Example Applications

Example application was tested with N97 and N8 Can be found from following link:

This page was last modified on 26 July 2012, at 03:11.
27 page views in the last 30 days.