Join Now
Quality Rating:
  • Currently 5.0 / 5
(5.0 / 5 - 1 vote cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 11:51, 28 March 2008.

CS000870 - Custom control: In dialog

From Forum Nokia Wiki


ID CS000870 Creation date March 28, 2008
Platform S60 3rd Edition, FP1 Tested on devices Nokia N95
Category Symbian C++ Subcategory UI


Keywords (APIs, classes, methods, functions): CCoeControl, CAknDialog

Overview

This example extends the Custom Control example CS000859 - Custom control. In this code snippet, the CMyControl custom control is added 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

RESOURCE DIALOG r_dialog
    {
    flags = EAknDialogGenericFullScreen;
    buttons = R_AVKON_SOFTKEYS_OK_BACK;
    items =
        {
        DLG_LINE
            {
            // CMyControl custom control type (defined in multiviews.hrh)
            type = KMyCustomCtl;
            // CMyControl custom control id (defined in multiviews.hrh)
            id = KMyCustomCtlId;
            control = CUSTOMCONTROL
                {
                txt = STRING_r_custom_control_dialog;
                };
            }
        };
    }

CMyDialog dialog header that defines the needed CreateCustomControlL()

#include <akndialog.h>
 
class CMyDialog : public CAknDialog
    {
    public:
        static TInt RunDlgLD();
        void PreLayoutDynInitL();
        
    private:
        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();
            break;
            }
        default:
            break;
        }
    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::RunDlgLD();

Postconditions

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:

Related Discussions
Thread Thread Starter Forum Replies Last Post
Can we get a popdown listbox control gigglie Symbian User Interface 1 2008-07-18 11:28
CAknDialog 的用法 liuxingyu_best Symbian 3 2008-07-06 01:43
Focus Problem Nilesh_Kul Symbian User Interface 0 2003-06-05 12:41
Custom FEP aware editing control dfdzgz Symbian User Interface 2 2008-07-23 10:49
Dialog Box amitaggarwal General Symbian C++ 1 2004-05-20 12:04
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZseriesE5f60Q
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX