diff -r 51a74ef9ed63 -r ae94777fff8f Symbian3/SDK/Source/GUID-96E46D0E-1CE3-58B4-AE99-6B2E622ADAF9.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-96E46D0E-1CE3-58B4-AE99-6B2E622ADAF9.dita Fri Jun 11 12:39:03 2010 +0100 @@ -0,0 +1,66 @@ + + + + + +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:

    +
  • RWindow::Invalidate(const +TRect &)

  • +
  • RWindow::BeginRedraw()

  • +
  • RWindow::EndRedraw()

  • +
  • CWindowGc::Activate(RDrawableWindow +&)

  • +

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.

+
Build

The Symbian +build process describes how to build this example.

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
    +
  • Transparent +Windows

  • +
+
\ No newline at end of file