Click on the following link to download the example: Transparent.zip
Click: browse to view the example code.
This example application demonstrates how to implement the following:
creating transparent, non-transparent and blank windows,
changing the transparency of a window,
drawing content on a window.
Creating transparent windows
This example creates a background and a foreground window using the RWindow class. The CPeriodic class triggers periodic redraws on the window. The following functions are used to re-draw content on the window:
The transparency of the foreground window is changed using the following functions:
RWindow::SetTransparencyAlphaChannel() : this function enables the use of an alpha channel to vary a window's transparency. The alpha value can be varied from 0 (fully transparent) to 255 (fully opaque).
RWindow::SetTransparentRegion(const TRegion&) : this function restricts the transparency to a specified region of the window.
Handling window server events
The user-defined class CEventHandler handles pointer events when transparent areas of the window are clicked by the pointer device. An appropriate message is displayed when a click event is detected.
The Transparent example builds an executable called transparent.exe in the standard location ( \epoc32\release\winscw\<build_variant> for Carbide.c++).
The example creates three windows:
One background window with height equal to the full emulator screen and width of half the emulator screen. The "Background Window" label is set for this window.
Two foreground windows each half the size of the background window are used to demonstrate the change in transparency . These windows can be identified by their labels.
1. Press the VaryTransparency button located at the bottom of the window to vary the first foreground window's transparency. The alpha value varies gradually from 0 to 255. This demonstrates calling the RWindow::SetTransparencyAlphaChannel() API.
2. Press the SetTransparent button to call RWindow::SetTransparentRegion(const TRegion&) on the bottom half of the second foreground window. This makes that half of the window transparent while the upper half stays opaque.
3. Click different mouse buttons to display the various popup messages
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License v1.0.