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 over the next few weeks. Thanks for all your past and future contributions.

Using a Symbian custom control in a dialog

From Wiki
Jump to: navigation, search
Article Metadata
Code ExampleTested with
Devices(s): Nokia N95
Keywords: CCoeControl, CAknDialog
Created: tepaa (19 Mar 2008)
Last edited: hamishwillee (30 May 2013)



This example extends the Custom Control example How to create a custom control in Symbian C++ to add the CMyControl custom control into CAknDialog.

MMP file

Add the following extra library because CAknDialog is used.

LIBRARY eikdlg.lib

Creating CMyDialog

Define a custom dialog that implements the CEikDialog::CreateCustomControlL() method.

The method creates a control line in the dialog. The line can thereafter be accessed through the identifier control ID. The control type is created by the Eikon control factory. If the value of control type is not known to the Eikon control factory, the construction of the control must be handled by CreateCustomControlL().

CMyDialog dialog resource in multiviews.rss

flags = EAknDialogGenericFullScreen;
items =
// CMyControl custom control type (defined in multiviews.hrh)
type = KMyCustomCtl;
// CMyControl custom control id (defined in multiviews.hrh)
id = KMyCustomCtlId;
txt = STRING_r_custom_control_dialog;

CMyDialog dialog header that defines the needed CreateCustomControlL()

#include <akndialog.h>
class CMyDialog : public CAknDialog
static TInt RunDlgLD();
void PreLayoutDynInitL();
SEikControlInfo CreateCustomControlL(TInt aControlType);

CMyDialog dialog implementation.

#include "cmydialog.h"
#include "cmycontrol.h"
#include <MultiViews.rsg>
#include "MultiViews.hrh"
TInt CMyDialog::RunDlgLD()
CMyDialog* dlg = new (ELeave) CMyDialog;
return dlg->ExecuteLD(R_DIALOG);
void CMyDialog::PreLayoutDynInitL()
CMyControl* control = (CMyControl*)Control(KMyCustomCtlId);
// TODO: tune components if needed
SEikControlInfo CMyDialog::CreateCustomControlL(TInt aControlType)
SEikControlInfo controlInfo;
controlInfo.iControl = NULL ;
controlInfo.iTrailerTextId = 0 ;
controlInfo.iFlags = 0 ;
switch (aControlType)
// CMyControl custom control type (defined in multiviews.hrh)
case KMyCustomCtl:
controlInfo.iControl = new(ELeave)CMyControl();
return controlInfo;

New enumeration values into multiviews.hrh

// CMyControl custom control type in resource file
enum {KMyCustomCtl = KAknCtLastControlId };
// CMyControl custom control id in resource file
enum {KMyCustomCtlId = 0x503 };

Launching the dialog.



CMyDialog is created by the dialog resource and CMyControl is created into the dialog line by calling CMyControl::ConstructFromResourceL(). CMyDialog implements the CEikDialog::CreateCustomControlL() virtual method that creates the custom control into the dialog line.

TODO: How to enable skins behind the dialog

See also

Custom Control Series:

This page was last modified on 30 May 2013, at 04:36.
66 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.