Transparent: Drawing Transparent Windows

Download

Click on the following link to download the example: Transparent.zip

Click: browse to view the example code.

Description

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:

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.

Build

The Transparent example builds an executable called transparent.exe in the standard location (\epoc32\release\winscw\<build_variant> for Carbide.c++).

Running the example

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

Related information