Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



How to construct a control

This section describes the functions that a concrete control class should implement so that it can be constructed.

Different functions are used to construct a control, depending on if it is:

The following sections describe each of the different cases. Each section begins by describing how the control is created by the application, and uses this to list the functions that the control needs to implement.

Note that device families may impose other requirements on control creation for use in dialogs.


Constructing a simple non-window-owning control

To do this, an application has to:

  1. Allocate memory for the control, and call its C++ constructor — this is done by calling new(ELeave) on the control class.

  2. Set the control's associated window — this is done using SetContainerWindowL().

The only construction function the control needs to implement in this case is its C++ constructor. This can be used to initialise control-specific data, and to call non-leaving functions that affect the control for its whole lifetime, such as SetNonFocusing().

A control of this type, whose construction involves functions that can leave, should also code a ConstructL() function to handle all aspects of initialisation that can leave.

[Top]


Constructing a compound control or a window-owning control

To do this, the application has to:

  1. Allocate memory for the control, and call its C++ constructor.

  2. If the control is a non-window-owning control, set its associated window, by calling SetContainerWindow() or SetContainerWindowL().

  3. Complete the control's construction by calling ConstructL().

  4. Activate the control by calling ActivateL(), unless the control is a component inside a compound control. In this case, there is no need to call ActivateL() explicitly, because when a compound control is activated, it also activates all its component controls.

The functions that the control needs to implement are its C++ constructor, and ConstructL(). ConstructL() is the control's second-phase constructor and should contain all initialisation that might leave. Typically, ConstructL() will:

The derived control class may optionally override ActivateL().